iPixel Posted April 30, 2009 Share Posted April 30, 2009 The script seems to run fine, just the file wont upload and i get the error msg i echo. <?php if($job == "uploadfile") { echo "Uploading file..."; // Where the file is going to be placed $target_path = "CompanyPolicies/"; // Add the original filename to our target path. //Result is "uploads/filename.extension" $target_path = $target_path . basename( $_FILES['thefile']['name']); if(move_uploaded_file($_FILES['thefile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['thefile']['name']). " has been uploaded"; } else { echo "There was an error uploading the file, please try again!"; } } else { ?> <form enctype="multipart/form-data" action="admin.php" method="post"> <input type="hidden" name="task" id="task" value="cp_upload" /> <input type="hidden" name="job" id="job" value="uploadfile" /> Choose a file to upload: <input type="file" name="thefile" /> <input type="submit" value="UPLOAD" style="height:20px; color:#993333;" /> </form> <?php } ?> Link to comment https://forums.phpfreaks.com/topic/156272-solved-my-upload-script-isnt-working-need-fresh-look/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 30, 2009 Share Posted April 30, 2009 Get php to tell you why the move_uploaded_file() is failing by turning on full php error reporting. Add the following two lines immediately after your first opening <?php tag - ini_set ("display_errors", "1"); error_reporting(E_ALL); Link to comment https://forums.phpfreaks.com/topic/156272-solved-my-upload-script-isnt-working-need-fresh-look/#findComment-822695 Share on other sites More sharing options...
iPixel Posted April 30, 2009 Author Share Posted April 30, 2009 Warning: move_uploaded_file(CompanyPolicies/TEST_PDF.pdf) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\Inetpub\wwwroot\Newton\cp_upload.php on line 26 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\php815.tmp' to 'CompanyPolicies/TEST_PDF.pdf' in C:\Inetpub\wwwroot\Newton\cp_upload.php on line 26 I assume this means the folder CompanyPolicies does not have permission to have files palced inside it ? Link to comment https://forums.phpfreaks.com/topic/156272-solved-my-upload-script-isnt-working-need-fresh-look/#findComment-822702 Share on other sites More sharing options...
iPixel Posted April 30, 2009 Author Share Posted April 30, 2009 Yep it was a permissions issue, all working fine now that all accounts have write permission to the folder. Thanks Link to comment https://forums.phpfreaks.com/topic/156272-solved-my-upload-script-isnt-working-need-fresh-look/#findComment-822714 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.