move_uploaded_file failure

前端 未结 10 1093
挽巷
挽巷 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:43

    With move_uploaded_file you don't need 777 permissions. What is the output of $path? Have you verified that $path exists? Have you verified that $field exists?

    Either $field or $path don't exist, or open_basedir is in effect is my guess.

    Is open_basedir restriction enabled? That could prevent the destination of the uploaded file from being written to. Look in your php.ini for open_basedir, if there's a path specified then it is enabled and you want to see if the destination path of your uploaded file is within this path. If it is, that's why it's failing.

    update

    $path cannot be a URL, it must be a local path such as /home/user/public_html/

提交回复
热议问题