kingzasz Posted January 5, 2004 Posted January 5, 2004 My file upload script is not working. Can anyone help? This is only part of my script, but I think it's the only part with problems: >$uploadDir = '/uploadedfiles/'; $uploadFile = $uploadDir . $_FILES['file']['name']; if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadFile)) { print "File is valid, and was successfully uploaded. "; } else { print "There was an error uploading the file. Please try again."; print_r($_FILES); exit; } This is the error I get, as well as my programmed error Warning: move_uploaded_file(/uploadedfiles/1210_14_2_web.jpg): failed to open stream: No such file or directory in /home/tcecom/public_html/upload2.php on line 56 Isn't this a problem with the server. Do I need to change permissions? Thanks Quote
Alan Posted January 5, 2004 Posted January 5, 2004 Ok, I aint sure if this is what your asking for, but it is helpful to me, and you might find what the problem is by looking through this Tutorial @ Dev's Articles: http://www.devarticles.com/c/a/PHP/Creatin...cript_in_PHP/3/ Quote
Alan Posted January 5, 2004 Posted January 5, 2004 Isn't this a problem with the server. Do I need to change permissions? Thanks If you think it is then you might try dropping a ticket and letting the TCH Staff take a look and see if they can find out what is going on. https://ssl.totalchoicehosting.com/supportdesk/ Quote
JesseD Posted January 5, 2004 Posted January 5, 2004 It looks like $uploadDir is set incorrectly. Try this: >$uploadDir = '/home/your_username_here/public_html/uploadedfiles/'; // Other code unchanged Where your_username_here is your TCH username. With PHP filesystem functions, pathnames are relative to the server root and not your own public_html directory. Your original code is trying to write to a directory just under the server root directory, which presumably doesn't exist (and of course, you wouldn't have permission to access it even if it did exist). Edited to add: Alternately, you could use a relative path such as >$uploadDir = 'uploadedfiles/'; Note that there is no slash at the beginning of the path. Maybe this is what you meant to do? Since the script is located in your public_html directory, 'uploadedfiles/' points to '/home/your_username_here/public_html/uploadedfiles/' That will work too, but I prefer to use complete path names whenever possible. That way a script doesn't break if you decide to move it to a different directory. Quote
kingzasz Posted January 6, 2004 Author Posted January 6, 2004 Thanks jesse, that did it! woooot Thank you all you guys for your suggestions. And thanks for the quick responses. Have a great day. Quote
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.