suess0r Posted May 10, 2007 Share Posted May 10, 2007 Hi, I'm trying to build an upload document option for my site. I'm having some issues with my form, but mostly with the updir.php which actually stores the file in a folder on the site. Here's what i got <form action="updir.php" method="post" enctype="multipart/form-data"> <label for="file"> <div align="center">Filename: <label> <input type="file" name="file" id="file" > <input type="submit" name="submit" value="Submit" > <br > </div> </form> and now updir.php <?php if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; echo "<br>"; } if (file_exists("/docs/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "docs/" . $_FILES["file"]["name"]; } ?> I'm getting the following errors back... Upload: BaumannProposal.doc Type: application/msword Size: 78 Kb Stored in: /tmp/phpSw4XSl Warning: move_uploaded_file(upload/BaumannProposal.doc): failed to open stream: No such file or directory in /home/content/s/u/e/suess0r/html/updir.php on line 22 Warning: move_uploaded_file(): Unable to move '/tmp/phpSw4XSl' to 'upload/BaumannProposal.doc' in /home/content/s/u/e/suess0r/html/updir.php on line 22 Stored in: docs/BaumannProposal.doc Anyone have any ideas? Also, once I can get this I want to password protect the directory so someone can log in and get to the documents... Little helppp? Quote Link to comment https://forums.phpfreaks.com/topic/50859-upload-document-option/ Share on other sites More sharing options...
Barand Posted May 10, 2007 Share Posted May 10, 2007 You check if it exists in docs/ folder. If it works, you report it is stored in docs/ folder. Yet you try to move it to upload/ folder ??? Quote Link to comment https://forums.phpfreaks.com/topic/50859-upload-document-option/#findComment-250194 Share on other sites More sharing options...
suess0r Posted May 11, 2007 Author Share Posted May 11, 2007 ehm, i was under the impression that if it existed already to cancel, but if it didn't to store in the /docs/ folder.... do u have any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/50859-upload-document-option/#findComment-250326 Share on other sites More sharing options...
Barand Posted May 11, 2007 Share Posted May 11, 2007 f (file_exists("/docs/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "docs/" . $_FILES["file"]["name"]; } Quote Link to comment https://forums.phpfreaks.com/topic/50859-upload-document-option/#findComment-250336 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.