hussainhakimuddin Posted September 12, 2011 Share Posted September 12, 2011 hi, i am trying to code a file uploader in php using IIS server this is the code of the form: <html><body> <form method="post" enctype="multipart/form-data" action="processform.php"> <input type="hidden" name="MAX_FILE_SIZE" value="200000"> <input type="file" name="thefile"><br/> <input type="submit" value="Submit File...."> </form> </body></html> this is the code of processform.php <?php $upload_dir = "C:/Inetpub/wwwroot/cbt/upload/"; $upload_file = $upload_dir . basename($_FILES['thefile']['name']); if(copy($_FILE['thefile']['tmp_name'],$upload_file)){ echo "File copy was Successful!"; } else { echo "Oops... something went wrong..."; print_r($_FILES); } ?> now the problem is each time i try to click on the submit button after browsing any file it shows the message : Oops... something went wrong...Array ( [thefile] => Array ( [name] => 1.jpeg [type] => image/jpeg [tmp_name] => C:\temps\php13.tmp [error] => 0 => 59592 ) ) help me guys...... wats the problem with the code ? Link to comment https://forums.phpfreaks.com/topic/246973-php-file-upload-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 12, 2011 Share Posted September 12, 2011 Probably a folder or a permission problem. Add the following two lines of code immediately after your <?php tag to get php to report and display any errors it detects - ini_set("display_errors", "1"); error_reporting(-1); Link to comment https://forums.phpfreaks.com/topic/246973-php-file-upload-error/#findComment-1268368 Share on other sites More sharing options...
hussainhakimuddin Posted September 12, 2011 Author Share Posted September 12, 2011 done that and this was the output Notice: Undefined variable: _FILE in C:\Inetpub\wwwroot\cbt\processform.php on line 8 Warning: copy() [function.copy]: Filename cannot be empty in C:\Inetpub\wwwroot\cbt\processform.php on line 8 Oops... something went wrong...Array ( [thefile] => Array ( [name] => 1.jpeg [type] => image/jpeg [tmp_name] => C:\temps\php59.tmp [error] => 0 => 59592 ) ) Link to comment https://forums.phpfreaks.com/topic/246973-php-file-upload-error/#findComment-1268372 Share on other sites More sharing options...
PFMaBiSmAd Posted September 12, 2011 Share Posted September 12, 2011 You are missing an S on one of the $_FILES Link to comment https://forums.phpfreaks.com/topic/246973-php-file-upload-error/#findComment-1268375 Share on other sites More sharing options...
hussainhakimuddin Posted September 12, 2011 Author Share Posted September 12, 2011 oooooooo Done that but now the new error is: Warning: copy(C:/Inetpub/wwwroot/cbt/upload/1.jpeg) [function.copy]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\cbt\processform.php on line 8 Oops... something went wrong...Array ( [thefile] => Array ( [name] => 1.jpeg [type] => image/jpeg [tmp_name] => C:\temps\php5A.tmp [error] => 0 => 59592 ) ) Link to comment https://forums.phpfreaks.com/topic/246973-php-file-upload-error/#findComment-1268377 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.