Solved

popup to upload file and set session values?

Posted on 2012-03-10
2
286 Views
Last Modified: 2012-03-15
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>
0
Comment
Question by:pillmill
2 Comments
 
LVL 16

Expert Comment

by:Chris Harte
ID: 37704735
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
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 37705286
This script will not work, even if you put session_start() at the top of the PHP because it has the HTML wrapper above the start-PHP statement. That creates browser output.  Browser output cannot come before cookies.  The session handler uses cookies. Thud.

Can you describe your question in non-technical terms?  It seems like there may be a standard design pattern that will meet your needs, but it's kind of hard to understand from what I have seen so far.

Thanks and regards, ~Ray
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now