Jump to content


Photo

COPY()


  • Please log in to reply
15 replies to this topic

#1 toter

toter
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 20 October 2006 - 06:22 AM

i am having trouble with the copy function.

<?php copy('file.php','newfile.php');?>
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


#2 JasonLewis

JasonLewis
  • Members
  • PipPipPip
  • Advanced Member
  • 3,351 posts
  • LocationVictoria, Australia

Posted 20 October 2006 - 06:45 AM

is file.php a file?
Good luck with your coding.
Jason / ProjectFear / Jaysonic

#3 toter

toter
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 20 October 2006 - 06:46 AM

yes

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 20 October 2006 - 06:54 AM

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:
chmod 777 -R .
(note the dot at the end)

#5 toter

toter
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 20 October 2006 - 06:58 AM

that would make sense but i just now checked in cpanel and all files and folders are set to 777

#6 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 20 October 2006 - 07:00 AM

Is safe-mode on?

#7 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 20 October 2006 - 07:00 AM

You might want to try this too:

print "I am in directory " . getcwd() . "\n";
print "My uid is " . getmyuid() . "\n";
print getcwd() . " is " . (is_writable(getcwd()) ? "writable" : "not writable") . "\n";

It's possible that newfile.php exists and the permission problem is there..

#8 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 20 October 2006 - 07:02 AM

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.

#9 toter

toter
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 20 October 2006 - 07:05 AM

You might want to try this too:

print "I am in directory " . getcwd() . "\n";
print "My uid is " . getmyuid() . "\n";
print getcwd() . " is " . (is_writable(getcwd()) ? "writable" : "not writable") . "\n";

It's possible that newfile.php exists and the permission problem is there..


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?

#10 toter

toter
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 20 October 2006 - 07:07 AM

Is safe-mode on?


safe-mode, how do i check/change that?
*note i am on a company server not my own.

#11 toter

toter
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 20 October 2006 - 07:10 AM

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.


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

got no errors

#12 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 20 October 2006 - 07:27 AM

Then try opening it with the w flag.

Also try to run this file:
<?php
header("Content-type: text/plain");
system('ls -l ..',$result);
echo $result;
?>
It should give you some rows like this:
drwxrwxrwx 49 www-data www-data 4096 Oct 19 15:16 www

Paste it here.

#13 toter

toter
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 20 October 2006 - 07:31 AM

Is safe-mode on?


ive tried this and it says no so safe-mode is off.
<?php if(ini_get('safe_mode')){echo "yes";}else{echo "no";}?>

thanks everyone who has helped me out,
tt

#14 toter

toter
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 20 October 2006 - 07:36 AM

Then try opening it with the w flag.

Also try to run this file:

<?php
header("Content-type: text/plain");
system('ls -l ..',$result);
echo $result;
?>
It should give you some rows like this:
drwxrwxrwx 49 www-data www-data 4096 Oct 19 15:16 www

Paste it here.

this is what i got: (Censored: <username>)
<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 />


#15 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 20 October 2006 - 07:38 AM

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

#16 toter

toter
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 20 October 2006 - 07:43 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users