PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?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.
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...
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...