Jesse Schokker
Jesse Schokker

Reputation: 896

PHP copy file permissions denied with dynamic user system

I am trying to copy a file to user's directory. I run a small hosting service with every user having a seperate directory. I can't CHMOD the directories to allow the PHP (www-data) user as that will break FTP for the users and some other programs we have installed on our server.

However, PHP (the www-data) user, is allowed to run with sudo. is this a possible fix? If it is: how to run copy() with sudo.

If that is not possible, is there another solution for my problem?

Exact error:

PHP Warning: copy(/home/user_946221/383838/Modules/xxx.zip): failed to open stream: Permission denied in /panel/handlers/server_functions/download.php

Thanks, Jesse

Upvotes: 1

Views: 529

Answers (1)

tomash
tomash

Reputation: 143

You should be able to do exec("sudo cp from to")

Best regards

Upvotes: 0

Related Questions