how to rename a file ?

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
ubsacc2004
Forum Newbie
Posts: 6
Joined: Thu May 14, 2009 1:16 am

how to rename a file ?

Post by ubsacc2004 »

hi all ,

below is my code but why i cant rename ? and it got error.

Code: Select all

 
 
<?php
    rename("Z:\\Moodle19\\server\\moodle\\Marking\\Suggested Answer DBF\\BACKUP-set2-4.ACC", "Z:\\Moodle19\\server\\moodle\\Marking\\Suggested Answer DBF\\BACKUP-set2-4.ZIP");
?> 
 
 
 
 
Thanks.
Last edited by Benjamin on Thu May 14, 2009 1:23 am, edited 1 time in total.
Reason: Changed code type from text to php.
Griven
Forum Contributor
Posts: 165
Joined: Sat May 09, 2009 8:23 pm

Re: how to rename a file ?

Post by Griven »

Are you sure you need to use double slashes? I've never used that function, and I don't have access to my server to test it right now...

If using single slashes doesn't work, consider the following:

It's important to note that, in general, your web application will not run with the same permissions as your own user account. Just because you can log onto the server and rename a file, does not mean that your web-service account can do the same.

Check the permissions on the file or folder that the file is contained in, and assign the correct permissions to the account.

You may want to check in with the security board and ask them about the implications of such an action before putting this into production, however.
User avatar
Hightower
Forum Newbie
Posts: 22
Joined: Tue May 12, 2009 7:09 am
Location: Durham, UK

Re: how to rename a file ?

Post by Hightower »

Any chance you could post the error you get? Would go a long way towards helping you. :)
ubsacc2004
Forum Newbie
Posts: 6
Joined: Thu May 14, 2009 1:16 am

Re: how to rename a file ?

Post by ubsacc2004 »

Griven wrote:Are you sure you need to use double slashes? I've never used that function, and I don't have access to my server to test it right now...

If using single slashes doesn't work, consider the following:

It's important to note that, in general, your web application will not run with the same permissions as your own user account. Just because you can log onto the server and rename a file, does not mean that your web-service account can do the same.

Check the permissions on the file or folder that the file is contained in, and assign the correct permissions to the account.

You may want to check in with the security board and ask them about the implications of such an action before putting this into production, however.
hi,


i sure i got permissions for the filepath due to i the administrator for this web server. I new in PHP. i just copy the code from website. So i dont know single slashes will solve or not. Will try it out.

Thanks.
Post Reply