I have a simple situation: some files are uploading via html form and POST method and upload.php is called.
In upload.php I have some php stuff like
<?php
// line one
// blah blah
is_uploaded_file(...);
// blah blah
move_uploaded_file(...);
// blah blah
So, when this script starts to execute (reaches the 'line one')? When I click the submit button or when the file is fully uploaded? Can I call another php script and both script will be executed at the same time? What happens if the global object $FILES I use in loop in the another script is unset when move_uploaded_file() is called by upload.php?
Your "line one" gets executed once the file(s) are uploaded (or better said, processed by PHP as they come in encoded as multipart/form-data from your POST form, see here). But some of the files could fail to upload, and you'll have error information at $_FILES global array, see here, for several reasons.
If the file(s) are OK, they'll be found at a temporary directory and temporary names (hence the need to call move_uploaded_file()).
So you could have two different users (or browsers) submitting the same files at the same time but they would be processed apart (i.e. 4 files x 2 calls, you'll get 8 temporary files), if that's your question.
Also, as per your question, one PHP execution cannot unset the $_FILES array for the execution of the other, same script. Another story is if you end writing the same path and filenames when calling move_uploaded_file(), you'll end with 4 files. As a little advice, you have to better understand the flow of an http request to the webserver (a POST with files in your case), that is then processed by your PHP script which outputs a response to the webserver that is sent back to the client (the browser).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With