I’ve written a bit of code to upload a file to a server. When the file is successful I made my code go to another web page. On this web page I want to print the file properties which were gained from the previous page so I am using Sessions in PHP.
//Starts up a new PHP session
session_start();
$_SESSION['file']=$_FILES["file"];
$_SESSION['name']=$_FILES['name'];
$_SESSION['type']=$_FILES['type'];
$_SESSION['size']=$_FILES['size'];
$_SESSION['tmp_name']=$_FILES['tmp_name'];
That is my session on page1. Then, when the file is successful, I send the user to page2.
header( 'Location: page2' ) ;
Now, on page2, I have this right at the top of my .php page:
<?php
//Starting session
session_start();
?>
Then, further down for me to be able to print each variable out I’ve got:
<?php
Print_r ($_SESSION['file']);
?>
I get all my information all jumbled into a long sentence when this is done. I want to have control over the information and print it nice and neatly. What am I doing wrong? I’ve researched into loads of different ways of doing this and nothing has helped so far.
Tried that, also tried just printing SESSION, also tried echoing each one seperately with the words [Array] being printed only.
Thanks in advance!
Use two dimensional array like below
on file2.php