Q:

Reattach a csv file to form after submitting initial form

I have a form that is just a file input, this file input is meant to attach CSV files to, and then you submit it and it gives you a list of all the headers to chose from. Once you are done making selections, I want to submit another form with these choices along with the CSV file to process.
My problem is that I can't figure out how to reattach the CSV file to the 2nd form.
I thought about just using an array to just POST the data, but wouldn't it be better to just reattach the CSV file and handle it properly?
This is what I have, I tried to look this up but couldn't find anything.
<input type="file" name="fileToUpload" value="<?=$_FILES['fileToUpload']['tmp_name'];?>">

That is in the 2nd form, after the initial attachment. How can I attach the CSV file to the form to process?

A:

What you're describing is impossible - you can't use PHP to write a file into a "file" input - it represents a location from the user's disk (not known to you on the server side) and only retrieves the actual file contents at postback. 
Instead I suggest that after the first form submission, you store the file on the server's disk in a temp location, and store the location in the session (or DB, or any other persistent storage), then on the 2nd postback retrieve the location and continue using the file. That way you don't have to request it again. 
Once you're done with the file you can delete the temporary file, or if that's not practical within the lifetime of the request, have a secondary job that clears the temp files folder of all "processed" files (and any files where the user never submitted the second form and their session has ended) at regular intervals.

