CCloudyVision Posted October 3, 2007 Share Posted October 3, 2007 Hello, I have a very simple script and am not interested in security. That being said, I cannot get it to work and I was wondering if you good people could help me find out why. I am an amateur as I am sure you all can tell so please be gentle Form.php HTML: <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> Uploader.php php: <html> <head> <title>Untitled</title> </head> <body> <? $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } ?> </body> </html> I copied this verbatim from one of the tutorials so I am not trying to claim this as my own but I cannot get it to work. The only message I get after trying to upload is the "There was an error..." message. Any help is appreciated. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/71699-upload-code-question/ Share on other sites More sharing options...
ploppy Posted October 3, 2007 Share Posted October 3, 2007 first thing i would check, is the directory writable where the file is being uploaded to? Quote Link to comment https://forums.phpfreaks.com/topic/71699-upload-code-question/#findComment-360965 Share on other sites More sharing options...
CCloudyVision Posted October 5, 2007 Author Share Posted October 5, 2007 The directory is public and unsecured. Isn't that the same as writable? Quote Link to comment https://forums.phpfreaks.com/topic/71699-upload-code-question/#findComment-362551 Share on other sites More sharing options...
deadonarrival Posted October 5, 2007 Share Posted October 5, 2007 "I have a very simple script and am not interested in security." - PLEASE don't start writing PHP code with this attitude, you'll get into problems later on. And no, writable depends on permissions... check the permissions on the file (you can do it through cPanel if you have it) Quote Link to comment https://forums.phpfreaks.com/topic/71699-upload-code-question/#findComment-362611 Share on other sites More sharing options...
CCloudyVision Posted October 6, 2007 Author Share Posted October 6, 2007 OK, I have finally got an error message: PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0 What does it mean "unknown" on line 0? Quote Link to comment https://forums.phpfreaks.com/topic/71699-upload-code-question/#findComment-363363 Share on other sites More sharing options...
MasterACE14 Posted October 6, 2007 Share Posted October 6, 2007 it means you got a pain in the neck of an Error. Let me go through your code again. I got nothing :-\ compare your script to this working upload script and see if you can get something from it. HTML: <form action="uploader.php" method="post" enctype="multipart/form-data"> <input type="file" name="file" size="45"> <br> <input type="submit" value="Upload File"> </form> uploader.php: <?php if( $_FILES['file']['name'] != "" ) // theirs your first bit of security, its really not hard { copy ( $_FILES['file']['tmp_name'], "C:/Apache/htdocs/" . $_FILES['file']['name'] ) // the directory to send the file or die( "Could not copy file" ); // more security } else{ die( "No file specified" ); } // the last of the security ?> see what you come up with, you might just trip over the answer you've been looking for. Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/71699-upload-code-question/#findComment-363364 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.