|
Posted by Steve Cook on 06/18/06 18:45
Description:
------------
I understand that PHP is server-side and this should really not happen,
but I have an issue I can't seem to crack. Any help would be greatly
appreciated.
I have a purely PHP back-end page, no HTML, that works fine in Internet
Explorer, however, it does not work correctly in either Firefox or
Opera. Moreover, the user never actually see the page in his/her
browser question because it is the back-end of an upload form.
>From everything I can tell the page simply cannot access the $_SESSION
variable. However, if I add "print $_SESSION['username'];" to the
following code, and directly visit the page, it correctly prints
$_SESSION['username'].
Reproduce code:
---------------
<?php require_once('/dp/siteData.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
function storPath($fileType){
if(stristr($fileType, ".avi") === TRUE || stristr($fileType,
".mov") ===
TRUE){
return 'media';
} else {
return 'images';
}
}
$uploadFile = $_SESSION['username']."_".
basename($_FILES['Filedata']['name'] );
$storage = storPath($uploadFile);
//path name of file for storage
$uploadFilePath = $storage."/".$uploadFile;
//if the file is moved successfully
if ( move_uploaded_file( $_FILES['Filedata']['tmp_name'] ,
$uploadFilePath
) ) {
//populate session array to be passed to SQL
$_SESSION['upFile'][] = $uploadFile;
echo( '1 ' . $_FILES['Filedata']['name']);
//file failed to move
}else{
echo( '0');
}
?>
Expected result:
----------------
If the uploaded file is named "james_2003.jpg" and
$_SESSION['username'] =
"wilson" I expect the file to be saved on the server as
"wilson_james_2003.jpg". However, it is correctly saved in IE.
Actual result:
--------------
File is saved simply as "_james_2003.jpg". It correct appends "_",
however, it doe not append $_SESSION['username'].
Navigation:
[Reply to this message]
|