Page 1 of 1

File Upload

Posted: Sat Nov 04, 2006 10:57 am
by tecktalkcm0391
I am using this code:

Code: Select all

<?php

$uploaddir = 'images/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
   echo "File is valid, and was successfully uploaded.\n";
} else {
   echo "Possible file upload attack!\n";
}

echo 'Here is some more debugging info:';
print_r($_FILES);

print "</pre>";

?>
And getting this:
File is valid, and was successfully uploaded.
Here is some more debugging info:Array
(
[userfile] => Array
(
[name] => untitled.JPG
[type] => image/pjpeg
[tmp_name] => /var/tmp/phpoy40P1
[error] => 0
[size] => 4354
)

)
And I can't figure out why!
Can anyone help... I've been trying for ever.

Posted: Sat Nov 04, 2006 11:01 am
by volka
:?:
Forgive me beeing dumb but is there a problem?

Posted: Sat Nov 04, 2006 11:05 am
by tecktalkcm0391
Yeah, sorry I didn't really state the problem but the file doesn't upload at all.

Posted: Sat Nov 04, 2006 11:07 am
by feyd
Your code results would suggest otherwise.

Posted: Sat Nov 04, 2006 11:12 am
by nickvd
Try modifying as follows:

Code: Select all

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
   echo "File is valid, and was successfully uploaded.\n";
   echo 'The File that was uploaded was placed here -----> '.$uploadfile."\n\n\n";
} else {
   echo "Possible file upload attack!\n";
}
Check (either via browser or via ftp, or if local via windows explorer) if the file exists in the location that gets reported... it'll be there, as your if statement will make sure of it...

Posted: Sat Nov 04, 2006 11:14 am
by tecktalkcm0391
Yeah I know but the file doesn't show up in the folder...

Posted: Sat Nov 04, 2006 11:15 am
by tecktalkcm0391
nickvd wrote:Try modifying as follows:

Code: Select all

if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
   echo "File is valid, and was successfully uploaded.\n";
   echo 'The File that was uploaded was placed here -----> '.$uploadfile."\n\n\n";
} else {
   echo "Possible file upload attack!\n";
}
Check (either via browser or via ftp, or if local via windows explorer) if the file exists in the location that gets reported... it'll be there, as your if statement will make sure of it...
Thanks, I got it. I feel stupid now.... :oops:

Posted: Sat Nov 04, 2006 11:44 am
by jayshields
Are you going to let us know how you solved the problem?