move_uploaded_file failure

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

    Basic debugging steps:

    • What does a print_r($_FILES) look like?
    • Does the source file actually exist?
    • Is the "error" flag of the file upload zero (will be visible when doing the print_r)
    • What does the target $path look like?
    • Are you specifying a full file name in the target path?

    My guess is that $path is only a path to a folder, not to a full file name.

    Update: You need to specify a filesystem path as $path.

提交回复
热议问题