views:

238

answers:

1

I'm relatively new to both hosting and PHP, so apologies for (probably) missing the obvious, but…

I built a page which would allow file uploads to my site, following the example laid out here:

W3Schools PHP upload exercise

Through the File Manage on my Godaddy hosting, I created a folder named ’upload’ so that the file would land there after being uploaded through the page I had built.

Part of the returned page that appears after submitted the file reads:

Temp file: d:temptmpphpE4C9.tmp
Stored in: upload/testfile.txt

which would indicate that the file has been sucessfully uploaded given the code in the example. However, I cannot see the file in the ’upload’ folder via my File Manage, or anywhere else on the hosting of my site (as far as I can see). I also cannot see the ’temp’ folder anywhere either…

Any help or clarification would be greatly appreciated.

+2  A: 

Actually, after reviewing the script, the message "Stored in: upload/testfile.txt" is printed regardless if the upload failed or not. Most likely move_uploaded_file is failing due to a permissions problem. Ensure your uploads directory is writeable by the webserver. Try chmod'ing it to 777 to test this (you shouldn't leave it like that without security restrictions as anyone could upload an executable file and try to run it!).

webbiedave
Good spot. move_uploaded_file returns false if it fails but no check is done on the return value from this function call.
Stephen Curran
Thanks Dave. I too thought it might be a permissions problem, but I've checked the folder settings and they all inherit from the root which is set as 'Web Viewable' and 'Web Writable'. I have no idea how I would have the permission to 777 in this GoDaddy account. Am thinking of changing host as this is driving me potty!
I certainly hope that your entire web tree is not world writeable. You'll need to study up on reading/setting permissions through an FTP client. You'll want to master that concept for sure as you'll run into it time and time again.
webbiedave
This is definitely a permissions problem - thanks. I've tried the upload on a different hosting site and it works fine. So the problem appears to be with my GoDaddy windows hosted site - I cannot change the permission on the files on this site to 777. All the control panel allows is to set 'Web writable' and 'web viewable', no more. Does anyone know how I can work around this? Thanks
I'm glad I could track down the problem for you. I, for one, stay far away from godaddy hosting so I would have no idea how to go about doing that. You *should* be able to contact godaddy support for this as it's no doubt a common request.
webbiedave