文件上传时$_FILES['XX']['tmp_name']临时文件的有效期求解?
做一个业务,需要从用户上传的excel中提取数据,但是不需要保存excel。
我通过上传的临时文件$_FILES['excel']['tmp_name']来读取数据。但是这个临时文件会自动被清除吗?如果会被自动清除,临时文件的有效期是多久,linux(centos)下php(通过yum 安装)的临时上传文件又是保存在哪个目录?
谢过大神!
回复讨论(解决方案)
是的,会被自动清除。当请求结束时会被删除。
linux下你可以用phpinfo(); 查看临时目录的位置
有效期应该是linux 管理的吧
请求结束时会被删除。个人觉得直接保存文件,当使用完删除更好控制。
用户上传文件,保存数据之后,ulink临时文件即可。
$_FILES['excel']['tmp_name'] 表示的就是上传临时文件的绝对路径
上传临时文件的生存周期与处理上传的php程序相同(即程序结束,临时文件消失)
move_uploaded_file 函数可使临时文件提前消失
真心有用,谢过众大神。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to implement file upload and processing in FastAPI FastAPI is a modern, high-performance web framework that is easy to use and powerful. It provides native support for file upload and processing. In this article, we will learn how to implement file upload and processing functions in the FastAPI framework, and provide code examples to illustrate specific implementation steps. First, we need to import the required libraries and modules: fromfastapiimportFastAPI,UploadF

1. Open Kugou Music and click on your profile picture. 2. Click the settings icon in the upper right corner. 3. Click [Upload Music Works]. 4. Click [Upload Works]. 5. Select the song and click [Next]. 6. Finally, click [Upload].

With the advent of the digital age, music platforms have become one of the main ways for people to obtain music. However, sometimes when we listen to songs, we find that there are no lyrics, which is very disturbing. Many people hope that lyrics can be displayed when listening to songs to better understand the content and emotions of the songs. QQ Music, as one of the largest music platforms in China, also provides users with the function of uploading lyrics, so that users can better enjoy music and feel the connotation of the songs. The following will introduce how to upload lyrics on QQ Music. first

How to solve the slow upload speed of Win10 computer? When we use the computer, we may feel that the file upload speed of our computer is very slow. So what is the situation? In fact, this is because the default upload speed of the computer is 20%, so the upload speed is very slow. Many friends do not know how to operate in detail. The editor has compiled the steps to format the C drive in Win11 below. If you are interested, follow Let’s take a look below! Solution to the slow upload speed of Win10 1. Press win+R to call up run, enter gpedit.msc, and press Enter. 2. Select the management template, click Network--Qos Packet Scheduler, and double-click Limit to reserve bandwidth. 3. Select Enabled, which will bring

Upload speed becomes very slow? I believe this is a problem that many friends will encounter when uploading things on their computers. If the network is unstable when using a computer to transfer files, the upload speed will be very slow. So how can I increase the network upload speed? Below, the editor will tell you how to solve the problem of slow computer upload speed. When it comes to network speed, we all know that the speed of opening web pages, download speed, and upload speed are also very critical. Especially some users often need to upload files to the network disk, so a fast upload speed will undoubtedly save you a lot of money. Less time, what should I do if the upload speed is slow? Below, the editor brings you pictures and texts on how to deal with slow computer upload speeds. How to solve the problem of slow computer upload speed? Click "Start--Run" or "Window key"

As long as the computer is equipped with a camera, it can take pictures, but some users still don't know how to take pictures and upload them. Now I will give you a detailed introduction to the method of taking pictures on the computer, so that users can upload the pictures wherever they want. How to take photos and upload them on a computer 1. Mac computer 1. Open Finder and click the application on the left. 2. After opening, click the Camera application. 3. Just click the photo button below. 2. Windows computer 1. Open the search box below and enter camera. 2. Then open the searched application. 3. Click the photo button next to it.

How to write an algorithm to find the least common multiple in Python? The least common multiple is the smallest integer between two numbers that can divide the two numbers. In mathematics, solving the least common multiple is a basic mathematical task, and in computer programming, we can use Python to write an algorithm for solving the least common multiple. The following will introduce the basic least common multiple algorithm and give specific code examples. The mathematical definition of the least common multiple is: If a is divisible by n and b is divisible by n, then n is the least common multiple of a and b. To solve the minimum

To generate temporary files in Go, you can use two functions of the os package: TempFile and TempDir. TempFile creates a temporary file with a specified extension, example: os.TempFile("","example.txt"); TempDir returns the absolute path to the temporary directory, which can be used to create temporary files, example: os.Create(filepath.Join(os .TempDir(),"example.txt")). The system will automatically delete temporary files, which should be closed and deleted after use to release resources.
