Hi there

I'm curious as to the process that happens when uploading a file. In all cases of file uploads do the files get uploaded to a temporary folder before any execution of code happens?

If at all possible could someone provide a link to a page that explains the process behind form file uploads.

I'd really appreciate it ;)

Dani AI

Generated

Short answer: the browser sends the form as a multipart/form-data POST and the server stack (webserver + language SAPI) decides how to receive and buffer that byte stream. The multipart format is defined in the RFC and is what carries the file parts inside the HTTP request body (RFC 7578). MDN gives a good overview of how POST requests carry a request body and the content types used by forms (POST method overview).

Expanding on what said: in typical PHP deployments the PHP SAPI parses the incoming multipart body and writes uploaded parts to a temporary directory (the one set in php.ini) before your script runs. When your script starts it sees the uploaded file via the usual upload APIs and should move and validate it. The exact point when bytes hit disk versus memory depends on the server and its buffering settings — for example, Nginx has buffer and temp-file settings that control whether the request body is spooled to disk (nginx client body buffering docs).

Practical checklist: confirm php.ini limits (upload/post sizes) and upload_tmp_dir and ensure permissions/disk space; check webserver buffering settings if large uploads fail; validate file type/size before moving to permanent storage; consider chunked or streamed upload solutions if you need to avoid full buffering. For the deeper HTTP-level mechanics, see the RFC and the MDN notes above, and note pointed to a longer thread with step-by-step detail earlier in the thread.

Recommended Answers

All 3 Replies

if i remember re calling this. I believe if you do not specify a file location for the file to be uploaded i believe it uses a default temporary location within the php.ini file.

take a look at the php.net website for mor information

What I'm trying to find out is how http actually works. The actual process that isn't defined by code written by a developer. I'm not sure how else I can explain what I'm looking for.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.