Forum Moderators: coopster

Message Too Old, No Replies

Upload error

Sometimes an error, others not...

         

mipapage

3:14 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello - I'm having some trouble with a script, where the following errors are occurring when I'm on my clients computer but not when at a work computer.

Unfortunately my client is on holidays and I don't have their browser or platform data (tho it's IE and Win) and I'm not sure if they have a firewall.

Here are the errors:

Warning: set_time_limit() [function.set-time-limit]:
Cannot set time limit in safe mode
in /usr/www/mydomain.com/manager.php on line 93

Warning: fopen() [function.fopen]: open_basedir
restriction in effect. File(/var/tmp/phplIS9SO) is not
within the allowed path(s): (.)
in /usr/www/mydomain.com/manager.php on line 100

Warning: fopen(/var/tmp/phplIS9SO) [function.fopen]:
failed to create stream: Operation not permitted
in /usr/www/mydomain.com/manager.php on line 100

Warning: filesize() [function.filesize]: open_basedir
restriction in effect. File(/var/tmp/phplIS9SO) is not
within the allowed path(s): (.)
in /usr/www/mydomain.com/manager.php on line 100

Warning: fread(): supplied argument is not a valid stream
resource in /usr/www/mydomain.com/manager.php on line 100

and line 100:


$data = addslashes(fread(fopen($temp, "rb"), filesize($temp)));

Not being able to recreate the problem at work makes this a bit of a pain in the **s. Any ideas would be greatly appreciated.

coopster

3:40 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



It seems you have a security issue from the messages you are receiving. I'd start with safe mode [us3.php.net] in the manual and troubleshoot from there. First thing I would check though would be file and directory permission settings.

[edited by: coopster at 3:42 pm (utc) on Oct. 13, 2003]

mipapage

3:41 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Coopster - I'll check it out.

FWIW - They're using win 2000.

Is it just me though, or is it weird that the error goes off on their machines and not ours?

coopster

5:22 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I was posting an edit as you were responding...
Is it just me though, or is it weird that the error goes off on their machines and not ours?

I would start with file and directory permission settings. I assume you are logged in locally and the server is on the same network, correct?

mipapage

7:33 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not logged in locally, I think. I log in to the site as my client would, as the site is hosted in another country with another company with whom we are partners.

The weird thing is that in speaking with another client, they mentioned that they had the same error on one of their personal computers, but not the ones at the office.

I'm trying to get all of the details on systems etc., but it's weird to me as it seems that it should be a server side problem.

I've sent a bote to the hosting co., hopefully they'll have an idea wrt some of what you mentioned earlier... (file and directory setting etc...)

(the more I learn the more I want my own serevr...)

ergophobe

8:08 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




Is it just me though, or is it weird that the error goes off on their machines and not ours?

It's just you ;-)

No seriously, it isn't weird. As Coopster mentioned, the client server is running in safe mode. That is not the default install for PHP, so you do not have it set on your machine.

The first error is a direct result of being in safe mode, as it says in the error message.

The second and fourth errors are as well I think. I haven't checked, but I believe that there are basedir restrictions when running in safe mode (I've run into the same problem and it was caused by running under safe_mode, though of course that isn't the only reason you could run into it).

Errors 3 and 5 might also be related or could have to do with directory permissions.

Try setting your local machine to run in safe mode (set it in php.ini) and then see what you get locally.

Tom

mipapage

10:51 am on Oct 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try setting your local machine to run in safe mode (set it in php.ini) and then see what you get locally.

Thanks :-]


WRT the directory and permission settings, my hosting guy tells me...

trying to write to /var/tmp/ ...which you can't do. you're allowed to write to /usr/www/mydomain.com

This is all good and well, but isn't that something that he has to specify in the php.ini on the server? From what I read searching around, there is no workaround for this...

(something is telling me that I'm screwed here)

mipapage

3:09 pm on Oct 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay,

I'm still having the problem in msg#7 above. Any ideas?

No seriously, it isn't weird. As Coopster mentioned, the client server is running in safe mode. That is not the default install for PHP, so you do not have it set on your machine.

This still isn't clear to me:

I have uploaded the script to an external server. While on that server, I can always upload images, while my client can *sometimes* upload images. This should have nothing to do with what I have set on my machine, no?

Salsa

1:44 am on Oct 17, 2003 (gmt 0)

10+ Year Member



mipapage, are you using ereg() to validate/identify file extensions? If you are, you may simply need to change to eregi().

I had a similar experience some time ago. I could upload files to a client's site just fine. Sometimes the client could too. And the exact same script also worked fine for other clients. But this client would usually get my failure messages when trying to upload from his office computer.

The only difference between him and everyone else was that most of the files he was trying to upload had upper case extensions.

I hope it's as simple as that for you. I'm not sure under what conditions you call set_time_limit(), down on line 93, but if it's part of a validation condition, it may never get called when an upload goes smoothly. After that, fopen() will break if your validation has prevented the file from being saved to /var/tmp/. Then all operations on a file the script wrongly assumes is open will break, too.

mipapage

7:00 am on Oct 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Salsa,

Thanks for that great explanation! I'm a bit new to PHP but learning and loving it. That sounds like a picky little 'bug' you ran into.

Anyway, we aren't using ereg() in this case. I've spoken with our service provider and they've changed the temp directory in their php.ini so I'll have our clients try it out later today.

Cheers - mipapage

mipapage

10:09 am on Oct 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okay,

Some added information for the description of the error, maybe this will help someone?

  1. The image is being stored in a db.
  2. The error doesn't always occur.
  3. When it does, it gives the errors outlined in the first message. Oddly enough though, when you view the product page after 'attempting' to upload, the image isn't there but the image info is. I.E. the File size, File type etc. is recorded.

ergophobe

9:17 pm on Oct 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is there a size limit in effect?

coopster

9:53 pm on Oct 17, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Good point, ergophobe.
mipapage, you said the image info is recorded in the table, right? View the File size and compare it to the size/type of field you are attempting to write to (
DESCRIBE table;
will show that information).

mipapage

10:34 am on Oct 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello again to both of you!

Here's the word. Apparently it was a temp path thing. I have no idea why it would work sometimes yes and others no. Not knowing the exact setup of the server makes it tough for me to troubleshoot.

Anyway, to close the topic, the idea in msg#7 worked. They set the value for the temp directory in their php.ini file and viola! (that's right, viola), it works.

WRT file size restrictions I didn't get the data but have tried uploading up to the set (php) MAX_FILE_SIZE and it worked, for me. They were uploading 9k images as test files.