Hi,

I need to pass full content of $_FILES to third page but fail to do so. File is selected once in first page. It might look wierd but It has to work this way.

If I use session $_SESSION['csv_file'] = $_FILES; in page 2, I cannot read the content of the file in page 3.

Thanks in advance

1.php

<form action="2.php" method="POST" enctype="multipart/form-data">
   Please select CSV file : <input type="file" name="uni_file" /><br />
   <input type="submit" name="submit_button" value="Upload" />
</form>

2.php

if (! isset($_FILES['uni_file'])) { echo 'Fail'; exit; }

//Prints all nicely
echo '<pre>'; print_r($_FILES); echo '</pre>';

<form action="3.php" method="POST" enctype="multipart/form-data">
   <input type="hidden" name="hidden_csv_file_content" value="<?php echo serialize($_FILES); ?>" /><br />
   <input type="submit" name="submit_button" value="Upload" />
</form>

3.php

//Gives error: unserialize() Error at offset 5 of 9 bytes
$csv_file = unserialize($_POST['hidden_csv_file_content']);

echo '<pre>'; print_r($csv_file); echo '</pre>';

Recommended Answers

All 2 Replies

I said at the begining " It might look wierd but It has to work this way...." so no need to question why page 2 because I don't know too.

I did hidden fields too just like in my example above.

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.