Solved

popup to upload file and set session values?

Posted on 2012-03-10
2
306 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

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 110

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

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This article discusses how to implement server side field validation and display customized error messages to the client.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

630 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