Jump to content

$_FILES problem


Recommended Posts

Hello all,

 

I have a form that allows for multiple (no limit) file inputs. But, if the user forgets a field of the form and it brings them back to the form with an error, I need to bring the $_FILES values back with it. Hence, the form should be sticky, file inputs included.

 

I created a static variable $tempFiles. I have the following line of code in my page:

 

if($tempFiles!=null)
    $tempFiles+=$_FILES;
else
    $tempFiles=$_FILES;

 

I am trying to set $tempFiles equal to the array in $_FILES each time the page submits. But, if I already have array values in $tempFiles (from a previous page submit), I want the $_FILES values to be placed in the $tempFiles array. This way, when the page submits and hits no errors all files can be referenced in $tempFiles and uploaded successfully, instead of the user having to choose the files every time the page loads.

 

Yet, when I write:

 

print_r($tempFiles);
exit();

 

The array of $tempFiles is printed, and is correct if it is the first page submit. But if it is the second, third, etc. the array only has one element, and it's ['name'], ['type'] and whatnot are blank.

 

Can you copy over the values of $_FILES and then use them just as with $_FILES, or is this not allowed? Am I doing something wrong?

 

Sorry if my explenation is difficult to read through.

 

-Tim

Link to comment
https://forums.phpfreaks.com/topic/49983-_files-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.