php - multi-step form with file upload

前端 未结 3 1780
忘掉有多难
忘掉有多难 2021-01-20 18:19

I can\'t seem to find clarification. I have 7 steps and the second one is to upload a file. The problem I am having is that on the final step when I finalize the form and tr

相关标签:
3条回答
  • 2021-01-20 18:48

    You're probably looking for the file in the wrong place. PHP stores the file in a temporary location, given in the $_FILES array as tmp_name under the appropriate index. Here's a good place to refresh your basics: http://www.w3schools.com/php/php_file_upload.asp

    0 讨论(0)
  • 2021-01-20 18:54

    So do they mean I move it from the default temp folder into a temp folder I manage and then when they complete the form move it again to a final folder?

    Yes, exactly. You do the first move on the request that receives the files, because when that request is finished PHP would delete them if they still exist.

    See move_uploaded_fileDocs and Handling File Uploads.

    0 讨论(0)
  • 2021-01-20 19:08

    With "temp folder" they don't mean /temp.

    After the upload, you should actually save the file in some folder, maybe with the user's session id as name. Then, with the last step, you should move that file to its definitive location.

    Temp files (like, actual temporary file) are destroyed once the program who created them exits (that means usually, in php, after the next output page is sent to the client).

    0 讨论(0)
提交回复
热议问题