problem with rename function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

problem with rename function

Post by pelegk2 »

i am tying to rename a file name :

Code: Select all

Warning: rename(./PDF/1.pdf,./PDF/book1.pdf): Permission denied in web/int/updateFiles.php on line 59

that is on a lnux server an i cant succeed
why is this?what can i do?
thnaks in advance
peleg
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

does the script have write permission for that folder? Does it own the file?
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

iade some changes but

Post by pelegk2 »

now when i rename in th e same folder as the script everything is ok !
but when i do

Code: Select all

<?php
here everything is ok 
rename("1.pdf","p1.pdf)

but :
here
Warning: rename("/PDF/2/1.pdf","/PDF/p1.pdf"): Permission denied web/int/uf1.php on line 3

and here :
Warning: rename("./PDF/2/1.pdf","./PDF/p1.pdf"): Permission denied web/int/uf1.php on line 3


?>
what can i do?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you need write permission for all the directories you wish to manipulate.. you probably need to own them as well.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

but its a new folder i have made using ftp and its in my directory on the Host's server
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that doesn't mean apache uses the same user as your ftp connection..
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

iss it possible that i have he same problem when i am trying to d/l a file :
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="123.pdf"');
readfile('./PDF/1pdf');
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

generally, the apache user will be able to read the file, if it exists... depending on the defaults for permissions of uploading through ftp...
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

its to download the file
and the file that is d/l is corrupted :(
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it may be corrupted by having extra characters enter the stream.. do a binary comparison between the two files, one before download and one after..
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

how do i do that execly?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I generally use a text editor, like TextPad which has a file comparison function, or just load the files in binary mode. Generally the difference is a space or carriage return at the front or end of file accidently..
Post Reply