toter Posted October 20, 2006 Share Posted October 20, 2006 i am having trouble with the copy function.[code]<?php copy('file.php','newfile.php');?>[/code]produces an error:Warning: copy(newfile.php): failed to open stream: Permission denied in /home/cs115896/public_html/leaders/tod/copy.php on line 1all my files and folders are set to 777.does any 1 know why this is?thanks in advanced,TT Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/ Share on other sites More sharing options...
JasonLewis Posted October 20, 2006 Share Posted October 20, 2006 is file.php a file? Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111689 Share on other sites More sharing options...
toter Posted October 20, 2006 Author Share Posted October 20, 2006 yes Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111690 Share on other sites More sharing options...
Daniel0 Posted October 20, 2006 Share Posted October 20, 2006 The error says it all: "Permission denied". You do not have sufficient permissions to perform that action. Either you do not have read permissions on file.php or write permissions on newfile.php or the folder.Edit: You need permissions on the folder as well. Try this command in the folder: [code]chmod 777 -R .[/code] (note the dot at the end) Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111691 Share on other sites More sharing options...
toter Posted October 20, 2006 Author Share Posted October 20, 2006 that would make sense but i just now checked in cpanel and all files and folders are set to 777 Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111692 Share on other sites More sharing options...
Daniel0 Posted October 20, 2006 Share Posted October 20, 2006 Is safe-mode on? Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111694 Share on other sites More sharing options...
btherl Posted October 20, 2006 Share Posted October 20, 2006 You might want to try this too:[code]print "I am in directory " . getcwd() . "\n";print "My uid is " . getmyuid() . "\n";print getcwd() . " is " . (is_writable(getcwd()) ? "writable" : "not writable") . "\n";[/code]It's possible that newfile.php exists and the permission problem is there.. Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111695 Share on other sites More sharing options...
Daniel0 Posted October 20, 2006 Share Posted October 20, 2006 If it is 777 then user, group and others all have read, write and execute permissions on the file, so it should obviously be writeable. Try to open it with fopen and see if it is possible. Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111697 Share on other sites More sharing options...
toter Posted October 20, 2006 Author Share Posted October 20, 2006 [quote author=btherl link=topic=112091.msg454806#msg454806 date=1161327648]You might want to try this too:[code]print "I am in directory " . getcwd() . "\n";print "My uid is " . getmyuid() . "\n";print getcwd() . " is " . (is_writable(getcwd()) ? "writable" : "not writable") . "\n";[/code]It's possible that newfile.php exists and the permission problem is there..[/quote]ok i got this: (Censored:<username>)I am in directory /home/<username>/public_html/leaders/tod My uid is 33300 /home/<username>/public_html/leaders/tod is not writableso this means i cant write files to this folder via copy right? Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111700 Share on other sites More sharing options...
toter Posted October 20, 2006 Author Share Posted October 20, 2006 [quote author=Daniel0 link=topic=112091.msg454805#msg454805 date=1161327626]Is safe-mode on?[/quote]safe-mode, how do i check/change that?*note i am on a company server not my own. Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111701 Share on other sites More sharing options...
toter Posted October 20, 2006 Author Share Posted October 20, 2006 [quote author=Daniel0 link=topic=112091.msg454808#msg454808 date=1161327758]If it is 777 then user, group and others all have read, write and execute permissions on the file, so it should obviously be writeable. Try to open it with fopen and see if it is possible.[/quote]ktried this:[code]<?php fopen("file.php", "r");?>[/code]got no errors Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111702 Share on other sites More sharing options...
Daniel0 Posted October 20, 2006 Share Posted October 20, 2006 Then try opening it with the w flag.Also try to run this file: [code]<?phpheader("Content-type: text/plain");system('ls -l ..',$result);echo $result;?>[/code] It should give you some rows like this: [code]drwxrwxrwx 49 www-data www-data 4096 Oct 19 15:16 www[/code]Paste it here. Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111703 Share on other sites More sharing options...
toter Posted October 20, 2006 Author Share Posted October 20, 2006 [quote author=Daniel0 link=topic=112091.msg454805#msg454805 date=1161327626]Is safe-mode on?[/quote]ive tried this and it says no so safe-mode is off.[code]<?php if(ini_get('safe_mode')){echo "yes";}else{echo "no";}?>[/code]thanks everyone who has helped me out,tt Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111708 Share on other sites More sharing options...
toter Posted October 20, 2006 Author Share Posted October 20, 2006 [quote author=Daniel0 link=topic=112091.msg454814#msg454814 date=1161329254]Then try opening it with the w flag.Also try to run this file: [code]<?phpheader("Content-type: text/plain");system('ls -l ..',$result);echo $result;?>[/code] It should give you some rows like this: [code]drwxrwxrwx 49 www-data www-data 4096 Oct 19 15:16 www[/code]Paste it here.[/quote]this is what i got: (Censored: <username>)[code]<br /><b>Warning</b>: system() has been disabled for security reasons in <b>/home/<username>/public_html/leaders/tod/copy.php</b> on line <b>3</b><br />[/code] Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111709 Share on other sites More sharing options...
Daniel0 Posted October 20, 2006 Share Posted October 20, 2006 They may have put some restrictions on the filesystem commands as well then. I guess you would have to contact your host. Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111711 Share on other sites More sharing options...
toter Posted October 20, 2006 Author Share Posted October 20, 2006 you know the strange thing is that when i tried this before i used ftp url in the copy function. it worked only few times then pages started being blank. i thought maby too many ftp connections were being made?wierdwell probally will have to talk to my providers.thanks every 1,TT Quote Link to comment https://forums.phpfreaks.com/topic/24515-copy/#findComment-111713 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.