tx647 Posted September 26, 2008 Share Posted September 26, 2008 Hi there, I'm new here, and I got questions about the rename() function. Have been searching on Google for a while, but never got any luck. So, I have a script to move a file to another directory upon question. The syntax I'm using is rename($oldfile, $newfile). The old file resides in /usr/foo/, and I'm moving it to /usr/foo/trash/. I have changed the owner and group of both foo and foo/trash to apache. And to make it easy, I changed permissions of the file, foo and foo/trash directories all to 777. But the rename function always fails (checked many times my spelling and printed out the command query to double check). Also, there's another part to this problem. To test, I tried to do this same operation in /var/www/html directory. The problem is, rename() works on small files, but never on big ones (any thing bigger than 50M or so). I didn't think it was the problem, but I changed the php script memory limit environment variable to 200M. It didn't help at all any way. Any help would be greatly appreciated! xt Quote Link to comment https://forums.phpfreaks.com/topic/125959-php-rename-problems-please-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 26, 2008 Share Posted September 26, 2008 When learning php, developing php code, or debugging php code, always set error_reporting to E_ALL and set display_errors to ON to get php to help you. Add the following two lines immediately after your first opening <?php tag - ini_set ("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/125959-php-rename-problems-please-help/#findComment-651355 Share on other sites More sharing options...
tx647 Posted September 26, 2008 Author Share Posted September 26, 2008 Thanks for the reply! I actually have already set the error display to E_ALL. The message was not helpful at all: Warning: rename(/usr/foo/bar.mp4,/usr/foo/trash/bar.mp4): Permission denied in /*/myscript.php Quote Link to comment https://forums.phpfreaks.com/topic/125959-php-rename-problems-please-help/#findComment-651370 Share on other sites More sharing options...
tx647 Posted September 28, 2008 Author Share Posted September 28, 2008 Any body got a solution for this? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/125959-php-rename-problems-please-help/#findComment-652383 Share on other sites More sharing options...
wildteen88 Posted September 28, 2008 Share Posted September 28, 2008 The problem is you're trying to rename a file which you do not have permission to do. This can be sorted by setting the correct write permissions to the file/directory you're trying to rename. Quote Link to comment https://forums.phpfreaks.com/topic/125959-php-rename-problems-please-help/#findComment-652405 Share on other sites More sharing options...
tx647 Posted September 30, 2008 Author Share Posted September 30, 2008 Actually, as indicated in my original post, I've already set the owner and group of the directory/file to apache. Furthermore, I've also set the permission code to 777. I still couldn't perform the operation. Any idea? Quote Link to comment https://forums.phpfreaks.com/topic/125959-php-rename-problems-please-help/#findComment-654204 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.