move_uploaded_file failure

前端 未结 10 1114
挽巷
挽巷 2020-12-10 13:25

Can someone help me understand why this is returning false?

if ((move_uploaded_file($_FILES[$field][\'tmp_name\'], $path))) {

As in, potent

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-10 13:32

    I was facing the same problem.

    If your error says "Failed to open stream: Permission Denied" it means the PHP Server is not being capable of creating the new file inside your destination directory.

    Once you have set the Linux permissions on the directory (wich sounds like you did by making it 777) you should give that special permission to the PHP Server.

    If your folder is named "uploads", you should cd to the previous directory and use the next command:

    chcon -R -t httpd_sys_rw_content_t uploads
    

    That definetly solved my problem.

    Hope it helps.

提交回复
热议问题