开发者

php - multi-step form with file upload

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 try and access the temp file it says "Could not access file: ..." (saved in the default tmp folder).

Other multi-step tutorials say to keep it in a temp folder and then move to the approp开发者_如何转开发riate folder when complete. 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?


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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜