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 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2003
    Location
    Toronto, ON
    Posts
    50
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mkdir and safe_mode fun!

    Hey gang,

    I'm trying to perform a fairly simple task: create a directory, and copy a file to it.

    PHP Code:
    $dir $wwwroot."/new_dir";

    $source "/dir/file.txt";
    $dest $dir."file.txt";

    mkdir($dir);
    chmod($dir0777);

    copy($source,$dest); 
    The outcome of the script is that the directory is created, and assigned 777 permissions. Good so far, but then:

    Warning: SAFE MODE Restriction in effect. The script whose uid is x is not allowed to access /new_dir owned by uid y
    I did some checking at php.net, and apparently this is a reported bug. The permissions are set appropriately, but the owner isn't, rendering the folder useless to the script.

    This is a fairly basic function I'm trying to perform, so I'm sure others do it all the time, and there must be a workaround...anyone know what it might be?

    Thanks
    Thodyconsulting.com

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    try doing your own copy function..

    PHP Code:
    <?php
    function mycopy$src $filename $path ){
     
    $yaks implode'' file$src ) ) ;
     
    $fp fopen$path.$filename 'w' ) ;
     
    fputs$fp $yaks );
     
    fclose$fp ) ;
    }
    ?>
    technically that `should` work as apache (nobody) owns both the directory and the file you are creating , but no guarentees , also you should do some error-checking so the above is q&dirty
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

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