Avatar of pillmill
pillmill
 asked on

popup to upload file and set session values?

I would like to use a popup to upload a file and then to also
set $_SESSION values. These values should be saved after the
popup closes so that they can be used to fill fields in the main page.
The  popup, below, is not saving the $_SESSION values.
How can this be fixed?

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

 <?php
 if(!empty($_FILES) ){
$_SESSION['name']=$_FILES['in_file']['name'];  
echo  $_SESSION['name']; //for testing
}
?>  
   
</head>

<body>

<script language="javascript" type="text/javascript">

function popitup(url) {
      newwindow=window.open(url,'name','height=200,width=150');
      if (window.focus) {newwindow.focus()}
      return false;
}

</script>

<input type="file" name="in_file" id="in_file">
<input type="submit" name="submit">

</body>
</html>
JavaScriptPHPHTML

Avatar of undefined
Last Comment
Ray Paseur

8/22/2022 - Mon
Chris Harte

Even though it is a popup, it is still a separate page. You need to include the function session_start() as the first line of php in every page.

http://uk3.php.net/manual/en/function.session-start.php
ASKER CERTIFIED SOLUTION
Ray Paseur

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23