...

View Full Version : mkdir and safe_mode fun!



thody
10-24-2003, 05:49 PM
Hey gang,

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



$dir = $wwwroot."/new_dir";

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

mkdir($dir);
chmod($dir, 0777);

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

firepages
10-25-2003, 05:10 AM
try doing your own copy function..



<?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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum