简体   繁体   中英

move uploaded file to different user home folder as root in php

I'm creating a php proxy upload script to handle incoming file uploads from a desktop app.

File uploads are secured and only permitted people can send files but they all have a different user on a CentOS server thus each with a different home directory

This php upload proxy is on it own home directory

How can this file move the uploaded tmp file to a different home directory than its own?

I tried with full hope to chown the php file to root, but this doesn't work. Php isn't even executed when the file is requested.

how to permit this script to upload files wherever it wants? I obviously don't want to chmod 777 the (predefined) target directories

Assuming it's running under Apache, the INSECURE option is to allow the process itself (not the file) to run as root. Just to make doubly sure, this is a BAD option.

The better option is to create a directory in each user's home that allows write only access to PHP. No read, no execute, just a blind drop box. You can achieve this with ACL's or with permissions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM