Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am working on update feature for a CMS. But I stuck on this. The scenario is user will able to upload a zip file, the updater script will extract it and replace the old one.

I have a problem with replacing, I've done the following

<?php rename($old, $new);

I always get "Permission Denied"

using ftp_rename:

<?php
$conn = ftp_connect($host);
ftp_login($conn, 'user', 'pass');
ftp_rename($conn, $src, $dest);

I always get

Warning: ftp_rename(): Rename Failed. on....

Is there a proper way to do this ? thanks.


share|improve this question
    
I think you'd come across far less problems by using a database driven CMS rather than file based –  scrowler 43 mins ago
    
Hi @scrowler thanks, the cms is database driven, but it's for updating the whole cms. –  egig 41 mins ago
1  
Do you mean replacing your source code like an "upgrade" sort of procedure? Regardless, the reason you won't be allowed to do this is because the user that your web server (Apache?) is running as may not actually have permission to modify the files. You might need to allow the web server user to modify files in a chown/chmod fashion –  scrowler 39 mins ago

1 Answer 1

Depending on your linux distro, php actually executes command as a specific user. Check your apache (or whatever server you are using) settings and put the permission accordingly

For example in apache, it is set

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data

You can then change that upload folder to be owned by www-data

For more information you can read this useful discussion http://unix.stackexchange.com/questions/30879/what-user-should-apache-and-php-be-running-as-what-permissions-should-var-www

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.