...

View Full Version : move_uploaded_file error



speedy_rudolf
10-26-2009, 08:05 PM
Hi. I have the following code:

$timp=time();
$file_dir="./upload".$timp;
mkdir($file_dir, 0777);
foreach($_FILES as $fisier=>$fisiere)
{if(is_uploaded_file($fisiere['tmp_name']))
{move_uploaded_file($fisiere['tmp_name'], "$file_dir/$fisiere[name]");}}
Well...that is just part of the code...Anyway...After I use the form, I get the following error:
Warning: move_uploaded_file() [function.move-uploaded-file]: SAFE MODE Restriction in effect. The script whose uid/gid is 189252/189236 is not allowed to access /home/www/free/uv.ro/rudolf.uv.ro/php/upload1256583575 owned by uid/gid 81/81 in /home/www/free/uv.ro/rudolf.uv.ro/php/upload.php on line 9

Does anyone know what the problem is? Thanks you.

PS: line 9 is the last line of code I copied, and I'm using post to submit the form.

karlosio
10-26-2009, 08:14 PM
This is a side effect of having safe mode on in php, turn safe mode setting to off in your php.ini file

Check if its on by copying this into a new file called say, info.php, this will tell you that its switched on.



<?php phpinfo(); ?>

speedy_rudolf
10-26-2009, 08:17 PM
This is a side effect of having safe mode on in php, turn safe mode setting to off in your php.ini file

Check if its on by copying this into a new file called say, info.php, this will tell you that its switched on.



<?php phpinfo(); ?>


ok...I check if safe mode is on...then how do I turn it off? Cause I don't have access to php.ini on my server...

mlseim
10-26-2009, 08:20 PM
I wonder if this problem could be related to the "sticky bit" problem with mkdir and PHP ...

I'm not so good at explaining the issue, but it has to do with PHP making a directory
within a directory (sub-directory).


Try this:


$oldumask = umask(0);
$file_dir="./upload".$timp;
mkdir($file_dir, 01777); // or even 01777 so you get the sticky bit set
umask($oldumask);



More info at the bottom of this page:
http://php.net/manual/en/function.mkdir.php

And another description:
http://www.navioo.com/php/docs/function.mkdir.php

speedy_rudolf
10-26-2009, 08:31 PM
yep...still not working...but thanks anyway... :)

mlseim
10-26-2009, 08:39 PM
Try a directory not within the root ...
Create a new directory called "temp" and CHMOD to 0777 ...
Then do this:

./temp/upload".$timp

speedy_rudolf
10-26-2009, 08:42 PM
Try a directory not within the root ...
Create a new directory called "temp" and CHMOD to 0777 ...
Then do this:

./temp/upload".$timp

actually, the html and php are already in a folder ("php") with CHMOD set to 777



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum