Forum Moderators: coopster

Message Too Old, No Replies

Choosing tmp directory for uploads

What to do when shared hosting blocks system tmp?

         

eugenebarnes

6:53 pm on Sep 21, 2003 (gmt 0)

10+ Year Member



My shared hosting service issued this message:

... a setting will be put in place to restrict the ability of php scripts to issue certain types of shell commands. ... The most common impact will be if you employ scripts that write to the system /tmp area and then move items from that area to your own directories (such as Gallery). You will need to make a configuration change to have those scripts write to directories under your own account.

My hosting service says "change the settings in your script to point to a temp directory of your choice under your account". Sounds logical, except I have not been able to find anything that explains how to point to another temp directory without changing the server's php.ini settings.

I'm using a typical form that gets a file from the hard drive and passes the path to a PHP script that worked fine until the configuration change.

Anyone know how to modify a script so it uses a directory other than the system tmp?

TIA

justageek

7:04 pm on Sep 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ini_set('upload_tmp_dir','wherever_you_want');

eugenebarnes

10:46 pm on Sep 21, 2003 (gmt 0)

10+ Year Member



Thanks for the reply...

But according to the docs at php.net, 'upload_tmp_dir' cannot be changed with a script. It must be changed using php.ini or httpd.conf.

I gave it a try anyway with no luck. Any other suggestions?

jatar_k

2:45 pm on Sep 22, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Have you asked them? If they are so gung ho to mess it up they should also supply a solution.

marcs

2:47 pm on Sep 22, 2003 (gmt 0)

10+ Year Member



Can you create a directory under your account, give it 777 and use it as you would the /tmp directory?

coopster

3:57 pm on Sep 22, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



If you use the
php_info()
function to display the current state of PHP, you'll see the
upload_tmp_dir
directive. You are correct; the only way to set this directive entry is in php.ini or httpd.conf. The default for this directive is NULL. On my server, that shows up as no value. Have you actually tried to upload a file and move it to a directory within your own directories? If so, and you receive this error, then jatar_k is right, your ISP has failed miserably as a provider and it is time to find a better hosting partner.

eugenebarnes

6:39 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



If so, and you receive this error, then jatar_k is right, your ISP has failed miserably as a provider and it is time to find a better hosting partner.

I would agree except my hosting partner has been rather exceptional for the two years I've been with them.

There has been no flurry of complaints on their forum since the change. And I know there are lots of Gallery users... supposedly Gallery uses the same file upload technique I am trying to use.

Is there an alternate means of uploading files via form that I'm unaware of?

coopster

7:00 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



As far as the form goes, there are two essential parts:
  1. <form enctype="multipart/form-data" action="_url_" method="post">
  2. <input name="userfile" type="file">

Of course, you need the actual <form> tags as well as a submit button. But after that, it's all server-side processing. PHP is one of the easiest tools to get this done. I'm with jatar_k on this one. See post #4: contact the ISP to discuss your situation and ask them for the solution to the problem they have created.

jatar_k

7:24 pm on Sep 23, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Have you looked at the configuration in gallery to see if there are settings there for it?

eugenebarnes

11:39 pm on Sep 23, 2003 (gmt 0)

10+ Year Member



I finally got a reply from another user of my hosting service. He also has a file upload script and it was totally unaffected by the sysem update. He pointed out that his script does not explicitly define a tmp directory... and neither does mine. Our methods are identical.

So it looks like I may have inadvertantly broken my script about the same time as the system change and the notice from the administrators lured me to suspect the wrong thing.

At least that's what I hope. A most likely scenario since there would have been a deluge of complaints if the system update *did* break the ability to upload via form.

I'm going to do some more diagnostic testing of my script to find out why it isn't working anymore.

Thanks to all who replied! Your comments were helpful in figuring out where to look.