Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

upload_tmp_dir saga part3

Status
Not open for further replies.

Dweezel

Technical User
Joined
Feb 12, 2004
Messages
428
Location
GB
This continues on from the 'PHP hosting recommendations' thread below, but the discussion had moved so far off php recommendations that I thought I should start another thread. It is also related to this thread which I posted in may:
The reason that the thread was titled 'hosting recommendations' is that I've been searching for a soloution to a problem caused by settings on my remote server, and I was about to throw in the towel and find another one.

The problem, or so I believed, is caused by the upload_tmp_dir setting in the php.ini on my server not being set to a temporary directory, which I thought prevented me from using php's http file upload functions However, lots of advice I am getting from other sources is telling me that this is unnecesary to making http file uploads work with php.

I sent an email to dathorn.com (a hosting provider) explaining my problem, and asked them about their upload_tmp_dir setting and he replied with the following:
When uploading through php using the php FILE features, the files are first uploaded to the /tmp directory. You may then copy it to your home directory. This is the way it is normally done by php programmers.

Likewise I've found a section in the php manual that says:
upload_tmp_dir

The temporary directory used for storing files when doing file upload. Must be writable by whatever user PHP is running as. [highlight]If not specified PHP will use the system's default.[/highlight]


After a few email replies from my hosting company that were little more that yes or no, I managed to get the following out of them(I'm guessing that this one may hold the key to solving my problem. I'm hoping the second part sounds a little less existential to you than it does to me):
PHP should currently upload correctly, and temp sessions are stored in /tmp/

php is running as nobody therefore the user nobody need to be able to write to any files and directories you are manipulating with php. What you need to do is make the directory owned by nobody or (less secure) writeable by all.

So my question is this (at last!). Can anyone tell me (or point me in the direction of a resource that could tell me) how I would go about utilizing this /tmp directory for file upload, given the last quote(the running as nobody one) from my hosting company?

Cheers! (sorry it was so long, thought I might as well give the full SP).

--

Note to Ingresman - Thanks a lot for all your help m8, but I can't get your script to run on my machine. I've tried every which way.
__
 
As far as getting the files from the user, through the connection, and to the server's filesystem, you don't have to do anything. PHP, so long as file uploads are enabled, will handle it automagically.

As far as getting to the data stored in the temp directory, that is well-documented in the PHP online manual section titled, "Handling file uploads".



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks Sleipnir. I've read that manual section, and in fact the code examples from that section are the ones that I've been using to test my file uploading (example 19-1 and 19-2).
Unfortunately all I get when I test them is permission errors. I'm guessing that this has something to do with that last quote from my hosting company. If you could enlighten me as to it's meaning I'd be very grateful. Thanks again.

This is the error message by the way:

Warning: move_uploaded_file(/home/mylogin/public_html/csmile.jpg): failed to open stream: Permission denied in /home/mylogin/public_html/uptest/upload.php on line 9
 
Solved it. Worked out that my hosts spiel was about file permissions. I've never changed file permissions before (I know, novice alert!), but having done that it now works and I'm uploading files (without an upload_tmp_dir setting I might add).

Hallelujah!!!!!

Thanks Ingresman and Slepinir for your help.
 
No worries, the power of chmod !!
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top