Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the temporary storage and recovery mechanism of $_ FILES of php

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the knowledge of "how to implement the temporary storage file and recycling mechanism of php $_ FILES". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I think people who have the same idea as me will deal with it like this: the uploaded file is just for temporary use, and there is no need to save the original file for backup, such as resize, and these late operations will only be performed during the second round of requests from the client, such as uploading first, returning the uploaded temporary file path to the browser, and then operating the temporary file after the user clicks. However, in the actual implementation, it was found that the temporary file did not exist in the second round of requests and could not be found in the temporary folder.

I also met someone in a Q group who asked this question, and the reason was similar to my realization idea. So, there is a doubt, how does uploading files work?

Do not want to look at the implementation code of php, I think roughly, it should be a recycling mechanism: click on the temporary file space, then php itself should maintain the recycling of this space

So I tried to upload a huge file, big enough to keep php running for a long time, and I thought I'd see it in a temporary folder. Unfortunately, I didn't see it until php returned: because the file exceeded the upload limit; then I used a small file upload to print out its temporary folder path and found that it started with php and ended with tmp.

I thought of a way to use whileto stop the process of uploading php and then return after a certain time. This time I saw the temporary file in the temporary folder, which was indeed named after php**.tmp.

If the php parsing is aborted by using the abnormal end php of the refresh page while php is running, then the temporary file will be retained permanently

If the php ends normally, the file will be deleted at the end of the php.

At the same time, I feel that this file should appear after the upload is complete: inference from the fact that I can't see it when I upload a large file.

Therefore, the temporary file maintenance method of php is to recycle resources as soon as the php is finished. If you want to use this file in the second round of requests, you should maintain the file after you move it.

In this test, we did not test the timing of recycling when multiple nesting situations of php include are tested.

This is the end of the introduction of "how to implement the temporary storage file and recycling mechanism of php's $_ FILES". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report