gsaldutti Posted November 13, 2008 Share Posted November 13, 2008 I got some very basic code from php.net for uploading images and no matter what image I try to upload from my computer as a test, I get the following result... Possible file upload attack! Here is some more debugging info:Array ( [userfile] => Array ( [name] => bradlidge.jpg [type] => [tmp_name] => [error] => 2 => 0 ) ) All my code is listed below. I don't get why there is some missing information in the global $_FILES. It's definitely a JPG, so why isn't '[type] => " showing JPG. It seems like this is such simple code but I cannot for the life of me get a simple image to upload into my "upload" folder. Any ideas? (And if anyone knows a good tutorial for learning to upload image files using PHP, please let me know). <html> <head> <?php // In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead // of $_FILES. $uploaddir = 'upload/'; $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>"; ?> </head> <body> <table WIDTH="980" CELLPADDING=5 CELLSPACING=5 BORDER=1 ALIGN=left> <tr> <td colspan=1> <form action="fillscript.php" method="POST" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="25000"> Upload Image: <input type="file" name="userfile"> <font size="1">Click browse to upload a local file</font> <input type="submit" value="Upload Image"> </form> </td> </tr> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/132499-solved-trouble-uploading-images/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 13, 2008 Share Posted November 13, 2008 http://us2.php.net/manual/en/features.file-upload.errors.php Link to comment https://forums.phpfreaks.com/topic/132499-solved-trouble-uploading-images/#findComment-688986 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.