electrix Posted June 28, 2007 Share Posted June 28, 2007 Before anyone says anything, YES I have searched on this forum and google without luck! <?php echo $_GET[filename1]." - GET<BR>"; $file = "/$_GET[filename1]"; $file2 = "/ny/$file"; rename('$file','$file2'); } ?> I want to move the file that is in "root" (aka "/") to the folder "ny". All the file/folder permissions is 777. The file still won't move or even copy to the folder or any other folder....? Anybody? Or maybe you know a better way to move a filer to a folder? Thanx in advance.. Link to comment https://forums.phpfreaks.com/topic/57579-renamemove-file-to-folder/ Share on other sites More sharing options...
no_one Posted June 28, 2007 Share Posted June 28, 2007 copy() should copy a file/folder... unlink() would delete it. Rename() doesn't move it at all as far as I know. http://us2.php.net/copy Link to comment https://forums.phpfreaks.com/topic/57579-renamemove-file-to-folder/#findComment-284997 Share on other sites More sharing options...
electrix Posted June 28, 2007 Author Share Posted June 28, 2007 So what is wrong with this then? <?php $file = $_GET[filename1]; if (!copy($file, /ny/$file)) { echo "failed to copy $file...\n"; } unlink($file); ?> Can it be something with the " /ny/$file " ? Link to comment https://forums.phpfreaks.com/topic/57579-renamemove-file-to-folder/#findComment-285003 Share on other sites More sharing options...
no_one Posted June 28, 2007 Share Posted June 28, 2007 In the code provided, the /ny/$file isn't quoted. if( !copy($file, "/ny/" . $file) ) { } Link to comment https://forums.phpfreaks.com/topic/57579-renamemove-file-to-folder/#findComment-285009 Share on other sites More sharing options...
electrix Posted June 28, 2007 Author Share Posted June 28, 2007 In the code provided, the /ny/$file isn't quoted. if( !copy($file, "/ny/" . $file) ) { } Nope it doesn't work.. I get the message "failed to copy" .... Link to comment https://forums.phpfreaks.com/topic/57579-renamemove-file-to-folder/#findComment-285011 Share on other sites More sharing options...
no_one Posted June 28, 2007 Share Posted June 28, 2007 Might want to try file_exists() to see if it's even there before copying. More absolute paths? or maybe "./ny/" or "./" . $file might help. I don't know what $file is really, just giving ideas. Is it a filename? or name+path? Link to comment https://forums.phpfreaks.com/topic/57579-renamemove-file-to-folder/#findComment-285021 Share on other sites More sharing options...
electrix Posted June 28, 2007 Author Share Posted June 28, 2007 Might want to try file_exists() to see if it's even there before copying. More absolute paths? or maybe "./ny/" or "./" . $file might help. I don't know what $file is really, just giving ideas. Is it a filename? or name+path? It's a filename.. And yes I've tried ./ and absolute paths.. Still not working.. Link to comment https://forums.phpfreaks.com/topic/57579-renamemove-file-to-folder/#findComment-285031 Share on other sites More sharing options...
electrix Posted June 28, 2007 Author Share Posted June 28, 2007 Ahh! I've got an error-message now... Warning: copy() [function.copy]: SAFE MODE Restriction in effect. The script whose uid is 200453 is not allowed to access / owned by uid 0 in /customers/randomriot.net/randomriot.net/httpd.www/move.php on line 14 failed to copy tradera.txt... Can someone tell me if there is a way to override SAFE MODE or another way to copy/move a file ? Link to comment https://forums.phpfreaks.com/topic/57579-renamemove-file-to-folder/#findComment-285042 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.