Upload File and Session Variables using IE5.5 and IE6.0

From: Date: Tue, 15 Apr 2003 08:15:31 +0000
Subject: Upload File and Session Variables using IE5.5 and IE6.0
Groups: php.qa 
Request: Send a blank email to php-qa+get-11336@lists.php.net to get a copy of this message
I have created a simple php code for uploading a single file and the code also contains session variables such as user name. I have observed that the file gets uploaded but the session variables becomes empty after upload. The code goes like this: -----------CODE FOR UPLOAD---------------- <?php session_register("User"); session_register("dest_dir"); if(@$HTTP_GET_VARS['Location']) $dest_dir=$HTTP_GET_VARS['Location']; if(@$HTTP_POST_FILES['txtSrcUpload']['size']>0){ $test =$dest_dir . "/" . $HTTP_POST_FILES['txtSrcUpload']['name']; copy ( $HTTP_POST_FILES['txtSrcUpload']['tmp_name'], $test); } ?> <html> <head> <title>Upload</title> </head> <!--<body onLoad="window.opener.document.test.txtSrcLocation.value='<?php echo $test; ?>';">--> <body> <?php if(@!$User){ echo "User does not exist."; } ?> <table width="100%">
     <tr>
       <td bgcolor="#BED2FF" valign="top" height="1"><b>
<font size="2" face="Arial">Upload File</font></b></td>
    </tr>
    <tr>
       <td valign="top" height="1"><b>
   	<font size="2" face="Arial">WelcomE <?php echo $User; ?></font></b></td>
    </tr>
    <?php
    if(isset($test) && $test!=$dest_dir){
    	echo "<tr><td><BR><font face=\"Arial\" size=\"2\"><B>File successfully uploaded.</B>";
    	echo "  <a href=\"\" onclick=\"window.close()\">Close</a></font></td></tr>";
    	}
    else{
    	echo "<tr><FORM ACTION=\"test.html\" enctype=\"multipart/form-data\" method=\"post\">";
    	echo " <td><font face=\"Arial\" size=\"2\"><i>Click Browse... to select the file to upload.</i></font><br>";
    	//echo "    <input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"15000000\"><br>";
       echo "    <input type=\"file\" name=\"txtSrcUpload\" size=\"60\"><br>";
	echo "    <input type=\"submit\" name=\"command\" value=\"Upload Now\" />&nbsp;";
       echo "    <input type=\"submit\" name=\"command\" value=\"Cancel Upload\" onclick=\"window.close()\" /></font><br><br>";
    	echo " </td>";
    	echo "</FORM>";
    	echo "</tr>";
    }
    ?>
</table> </body> </html> -----------END CODE FOR UPLOAD---------------- The code below is the calling page and the destination page after upload: -----------CALLING AND RECEIVING PAGE------------ <?php session_register("User"); $User = $HTTP_GET_VARS['user']; session_register("buffer");
    session_register("$dest_dir");
?> <html> <head> <title>test</title> <SCRIPT LANGUAGE="JavaScript"> <!-- Start var TimeOut = 300; var TimeRemain = 0; var RefreshRate = 2; var win = null; var site = ""; function PopUp(name, w, h, scroll) { var l = (screen.width - w) / 2; var t = (screen.height - h) / 2; site = "test.html?Location=" + window.document.test.txtSrcLocation.value; newwin = 'height='+h+',width='+w+',top='+t+',left='+l+',scrollbars='+scroll+',resizable' if (win)
    		return false;
win = window.open(site, name, newwin) win.creator=self ResetTimer(); if (TimeOut && RefreshRate) setTimeout("CheckClose();",RefreshRate * 1000); if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } } function ResetTimer() { TimeRemain = TimeOut; } function CheckClose() { TimeRemain -= (RefreshRate); if (TimeRemain > 0) { if (win && win.closed)
      {
win = null;
      }
else if (win)
      {
setTimeout("CheckClose();",RefreshRate * 1000);
      }
} else if (win) {
    if (win.closed)
win = null;
    else
{
        win.close();
win = null;
       }
} } // End --> </script> </head> <body onUnload="if (win){win.close()};"> <p>
       <b><font size="2" face="Arial">WelcomE <?php echo $User; ?></font></b>
    </p>
<form name="test" method="post" action="test.html">
    <?php
     if(@!$User){
echo "User does not exist.";
     }
       		$temp=$buffer['txtSrcLocation'];
       		echo "<font face=\"Arial\" size=\"2\"><i>Source Full Path (Directory and Name)</i></font><br>";
echo "<font face=\"Arial\" size=\"2\">"; echo "<input type=\"text\" name=\"txtSrcLocation\" size=\"60\" value=\"/input/\">"; echo "<br><br><i>Or Upload File from Local Machine &nbsp;</i> "; echo "<input type=\"submit\" name=\"command\" value=\"Upload File\" onclick=\"PopUp('test','550','180','no');return false;\"/>"; echo "</font><br><br>";
       ?>
</form> </body> </html> -----------END OF CALLING AND RECEIVING PAGE------------------- _________________________________________________________________ Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail

« previous php.qa (#11336) next »