Hey all. I’ve been working my way through learning some php, and while trying to implement one of the examples in the book I’m using have run into a snag. Basically, the code for the line that’s causing problems is:
if (move_uploaded_file ($_FILES['thefile']['tmp_name'], "../uploads/{$Files['thefile']['name']}")) {
print '<p>Your file has been uploaded.</p>';
However, when I upload my page to my server and try to run it, I get this error:
Warning: move_uploaded_file(../uploads/) [function.move-uploaded-file]: failed to open stream: Is a directory in /home/my_name/public_html/upload_file.php on line 16
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php35s8a3' to '../uploads/' in /home/my_name/public_html/upload_file.php on line 16
The php file is in the web root directory (public_html), and the folder uploads, with permissions set to 0777 is outside that directory, in the my_name folder which contains both public_html and uploads (per recommendation of the book I’m using).
It seems to not be able to see the directory. I tried this also putting the upload directory in a folder that was in public_html, but got the same error.
Any thoughts?
Damn, sorry for yet another post. But I MUST ADVICE, if you don’t know what you’re doing, don’t go messing around with a CHOWN command. Hell, or any other command for that matter either. You may need to ask your host to CHOWN the proper file, that is, if that’s even the problem here.
It seems that where I have randomly decided to use the variable $files, it ought to have been $S_FILES. It’s funny, I went over the source code comparing it to mine a bunch of times, and didn’t catch that I had made that error.