PDA

View Full Version : uploading files problem


bee80
02-04-2009, 06:27 PM
Using the php tutorial to upload files , cant get it to work do i need to edit php or mysql? I notice i have 2 errors and its not showing file type, tmp name etc,
so im guessing its not uploading to apache for some reason

Here's the php


<?php

echo "<pre>";
print_r($_FILES);
echo "</pre>";


//$target_path = "C:/Users/David/Desktop/WORK/remote/lessons/images/".$_FILES['uploadedfile']['name'];

//move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path);



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>



<form action="" method="post" enctype="multipart/form-data" name="form1">

<input type="hidden" name="MAX_FILE_SIZE" value="100000"/>

Choose a file to upload
<input type="file" name="uploadedfile" />

<input type="submit" name="Submit" value="Upload">

</form>
</body>
</html>





and here's the output for testing the array



Array
(
[uploadedfile] => Array
(
[name] => 010.JPG
[type] =>
[tmp_name] =>
[error] => 2
[size] => 0
)

)

davidj
02-04-2009, 06:51 PM
the code you posted has been commented out

therefore it wont run

also you cant output the contents of a variable until its been set

bee80
02-04-2009, 07:01 PM
I just followed your tutorial and changed target_path :)

i commented it out to test the array

Anyway ive fixed it, like an idiot i was trying to upload to big a file :/

so will uncomment the target path now and see

bee80
02-04-2009, 07:05 PM
sorry my mistake works like a dream now :D please delete thread

domedia
02-04-2009, 09:11 PM
please delete threadThat's not really how forums work :)

bee80
02-05-2009, 12:02 AM
lol i know but this is of no relevance , was just my stupid mistake its just wasting space :)

edbr
02-05-2009, 01:29 AM
no we all make mistakes, it can help someone. I owned up to wasting almost an entire day looking for an answer recently only to discover Id omitted a semi colon . it reminds us all to check our code and gie s examples of easy mistakes

davidj
02-05-2009, 06:45 AM
ahh the missing semi colon.... That ol chestnut

we have all walked that plank