kylebuch8 Posted September 23, 2006 Share Posted September 23, 2006 Hi, I've been having a lot of trouble uploading files from an HTML form to a directory on my server. I have set all of the appropriate permissions to 777 and I have used code from other topics on this forum to try to make this work. Here is the code that I am using for my HTML form. <form enctype="multipart/form-data" method="post" action="upload.php"> Send this file: <input name="userfile" type="file"><br> <input type="submit" value="Send File"> </form> Here is the code that I am using for upload.php. I have taken out my user name where all of the *'s are. <?php $uploadDir = '/home/********/public_html/images/'; $uploadFile = $uploadDir . basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadFile)) { echo "File {$_FILES['userfile']['name']} was uploaded successfully.\n"; } else { echo "Upload Failed!\n"; } ?> Here are the error messages that I am receiveing: Warning: move_uploaded_file(/home/********/public_html/images/aap_dyk_issue9_img1.gif) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/*******/public_html/upload.php on line 6 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpFbCAfc' to '/home/********/public_html/images/aap_dyk_issue9_img1.gif' in /home/********/public_html/upload.php on line 6 Upload Failed! I have been all over this forum and other tutorials for the past week and I still cannot get this to work. The error that I have been receiving from most of my attempts using a lot of different code seem to be around using "move_uploaded_file()". Any help on this would be appreciated. Thanks. Quote Link to comment Share on other sites More sharing options...
annie Posted September 24, 2006 Share Posted September 24, 2006 When you get it to work, be sure to disallow search engine robots from accessing the directory where the uploaded files are, or you'll be inundated with spammy pages quickly! There is a script made for file uploads that you could use. Just search for it. Also, the more scripts you have, the more holes you put in your site, and the more risk there is of a hacker gaining control over your site. Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted September 24, 2006 Share Posted September 24, 2006 Welcome to the forums kylebuch8 As annie states there are upload scripts already written and available. Check out hotscripts.com Quote Link to comment Share on other sites More sharing options...
jhollin1138 Posted September 24, 2006 Share Posted September 24, 2006 I tried your script and it worked fine for me, I would verify your permissions. Quote Link to comment Share on other sites More sharing options...
kylebuch8 Posted September 25, 2006 Author Share Posted September 25, 2006 Thanks everyone. The script worked as it should have. It turned out it was a problem with permissions. I felt like an idiot when I found that out. I've got everything worked out now. Thanks for all your help. Quote Link to comment 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.