Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Sep 2009
    Posts
    57
    Thanks
    6
    Thanked 0 Times in 0 Posts

    move_uploaded_file error

    Hi. I have the following code:
    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.

  • #2
    Regular Coder
    Join Date
    Dec 2006
    Location
    In the wilderness
    Posts
    106
    Thanks
    9
    Thanked 5 Times in 5 Posts
    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 Code:
    <?php phpinfo(); ?>
    "The advantage of computers is that they do exactly what you tell them to do. The disadvantage of computers, on the other hand, is that they do exactly what you tell them to do."

    Excellent resource for learning PHP here

  • #3
    New Coder
    Join Date
    Sep 2009
    Posts
    57
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by karlosio View Post
    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 Code:
    <?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...

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    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:
    PHP Code:
    $oldumask umask(0);
    $file_dir="./upload".$timp
    mkdir($file_dir01777); // 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

  • #5
    New Coder
    Join Date
    Sep 2009
    Posts
    57
    Thanks
    6
    Thanked 0 Times in 0 Posts
    yep...still not working...but thanks anyway...

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    Try a directory not within the root ...
    Create a new directory called "temp" and CHMOD to 0777 ...
    Then do this:

    ./temp/upload".$timp

  • #7
    New Coder
    Join Date
    Sep 2009
    Posts
    57
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mlseim View Post
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •