Jump to content

Archived

This topic is now archived and is closed to further replies.

toter

COPY()

Recommended Posts

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 1

all my files and folders are set to 777.
does any 1 know why this is?

thanks in advanced,
TT

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
that would make sense but i just now checked in cpanel and all files and folders are set to 777

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[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 writable

so this means i cant write files to this folder via copy right?

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites
[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]

k
tried this:
[code]<?php fopen("file.php", "r");?>[/code]

got no errors

Share this post


Link to post
Share on other sites
Then try opening it with the w flag.

Also try to run this file: [code]<?php
header("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.

Share this post


Link to post
Share on other sites
[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

Share this post


Link to post
Share on other sites
[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]<?php
header("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]

Share this post


Link to post
Share on other sites
They may have put some restrictions on the filesystem commands as well then. I guess you would have to contact your host.

Share this post


Link to post
Share on other sites
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?

wierd
well probally will have to talk to my providers.


thanks every 1,
TT

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.