
Originally Posted by
CrazyChop
...
Second, does the php script page which is supposed to create the folders have session_start() called before attempting to read information from the session?
Does the Java Applet upload communicates with PHP? PHP reads the header for information such as the file name and etc.
Yes, the php script page that is supposed to create the folders does call session_start() before it tries to access the session variables. Below is the code.
The java applet creates and sends the HTTP request just as an html form does. When I have the php script move the uploaded files to a static (previously) created folder that does not rely on session variables - the script successfully moves all uploaded files (from the java applet) to the static destination folder.
PHP script that creates on-demand sub-folders & moves uploaded files:
PHP Code:
session_start();
if ( isset($_SESSION["Id"]) && isset($_SESSION["topicId"]) && isset($_SESSION["topicTitle"]) ){
$newDir = "D:/Apache/htdocs/webtools/data/" . $_SESSION["Id"] . "/feature_image_galleries/" . $_SESSION["topicId"];
mkdir($newDir, 0777);
$path = $newDir . "/";
} else {
return false;
}
if ( file_exists($path) ){
for ($i = 0; $i < count($_FILES['imgFile']); $i++){
if ( file_exists($_FILES['imgFile']['tmp_name'][$i]) ){
$targetPath = $path . basename($_FILES['imgFile']['name'][$i]);
if ( move_uploaded_file($_FILES['imgFile']['tmp_name'][$i], $targetPath) ){
}
} else {
continue;
}
}
} else {
echo "Directory does not exist: " . $path;
}
echo "<pre>";
echo print_r($_SESSION);
echo "</pre>";
echo "<br/>";
echo "<pre>";
echo print_r($_FILES);
echo "</pre>";
Bookmarks