I've a script for uploading photos.
In the first page they have to fill in an form with username,
email and phonenumber.
Then a secondpage (php) is opened in which a javascript applet is
called to upload the files, after uploading i have two sessions.
One with the username, email and phonenumber and one with the
names of all the files.
The problem occurs that i want to store all photos in an folder
with username and date, but because of the double sessions this
is not happening.
What am i doing wrong?
Here is the code:
Page 1 (login)
<?php
// Start de session
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>inlog</title>
</head>
<body>
<form action="fotoupload.php?" method=post>
<p> </p>
<p align="center" class="style9">Voordat u foto's kunt uploaden vragen wij eerst wat gegevens van u: <br>
(Naam en Email verplicht, Telefoon voor als er nog eventuele vragen zijn) </p>
<table width="480" align="center">
<tr>
<td width="99"><span class="style3 style9">Naam:*</span></td>
<td colspan="4"><span class="style8">
<input type="text" name="f_name" size="50" maxlength="100">
</span></td>
</tr>
<tr>
<td class="style3 style9">Email:*</td>
<td colspan="4"><span class="style8">
<input type="text" name="email" size="50" maxlength="100">
</span></td>
</tr>
<tr>
<td class="style3 style9">Telefoon:</td>
<td colspan="4" class="style1"><span class="style8">
<input name="telefoon" type="text" id="telefoon" size="50" maxlength="11">
</span></td>
</tr>
</table>
<div align="center">
<INPUT name="submit" TYPE="submit" VALUE="Verder">
<input name="reset" type="reset" value="Herstellen">
</div>
</body>
</html>
Page 2 (fotoupload.php - calling applet)
<?php
// Start de session
session_start();
//f_name,email en telefoon save in session
$f_name = $_POST['f_name'];
$email = $_POST['email'];
$telefoon = $_POST['telefoon'];
$_SESSION['name'] = $f_name;
$_SESSION['email'] = $email;
$_SESSION['telefoon'] = $telefoon;
?>
<html><title>jupload</title>
<body>
<table width="640" height="460" border="0" align="center">
<tr>
<td>
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codetype="application/java-vm"
width="630"
height="300"
name="JUpload"
codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4-windows-i586.cab#Version=1,4,0,0">
<param name="archive" value="jupload_hafo.jar">
<param name="code" value="JUpload/startup.class">
<param name="progressbar" value="true">
<param name="boxmessage" value="Bezig met Laden...">
<param name="actionURL" value="../jupload_email/jupload.php">
<param name="customFileFilter" VALUE="true">
<param name="customFileFilterDescription" VALUE="foto's (jpg, bmp en tif)">
<param name="customFileFilterExtensions" VALUE="jpeg,jpg,bmp,tif,tiff">
<param name="autoselectLastFile" value="false">
<param name="labelFiles" value="Naam">
<param name="labelBytes" value="Grootte">
<param name="showTabViews" value="list">
<param name="hideShowAll" value="false">
<param name="useRecursivePaths" value="false">
<param name="realTimeResponse" value="false">
<param name="checkResponse" value="false">
<param name="showServerResponse" value="false">
<param name="maxTotalRequestSize" value="100000000">
<param name="checkJavaVersion" value="true">
<param name="checkJavaVersionGotoURL" value="http://java.com/nl/download/manual.jsp">
<param name="imageURL" value="../jupload_email/hafo.gif">
<param name="showSuccessDialog" value="true">
<param name="completeURL" value="../jupload_email/emailupload.php">
<param name="errorURL" value="../jupload_email/servererror.html>">
<param name="disableContextMenu" value="true">
<param name="debug" value="false">
<param name="mayscript" value="mayscript">
<embed type="application/x-java-applet;version=1.4.2"
width="630"
height="300"
code="JUpload/startup.class"
archive="jupload_hafo.jar"
name="JUpload"
pluginspage="http://java.sun.com/j2se/1.4/download.html"
progressbar="true"
boxmessage="Bezig met Laden..."
actionURL="../jupload_email/jupload.php"
customFileFilter="true"
customFileFilterDescription="foto's (jpg, bmp en tif)"
customFileFilterExtensions="jpeg,jpg,bmp,tif,tiff"
autoselectLastFile="false"
labelFiles="Naam"
labelBytes="Grootte"
showTabViews="list"
hideShowAll="false"
useRecursivePaths="false"
realTimeResponse="false"
checkResponse="false"
showServerResponse="false"
maxTotalRequestSize="100000000"
checkJavaVersion="true"
checkJavaVersionGotoURL="http://java.com/nl/download/manual.jsp"
imageURL="../jupload_email/hafo.gif"
showSuccessDialog="true"
completeURL="../jupload_email/emailupload.php"
errorURL="../jupload_email/servererror.html"
disableContextMenu="true"
debug="false"
mayscript="mayscript"
>
</embed>
</object>
</td>
</tr>
</table>
</body>
</html>
Page 3 (jupload.php - filesaving)
<?php
// Start de session
session_start();
// save alle uploaded files in session
$mail = "\nUPLOADS\n";
foreach($_FILES as $tagname=>$file){
move_uploaded_file($file['tmp_name'],$target);
$mail .= "\nFile: " . $file['name'];
}
$_SESSION['files'] = $mail;
// END
// MK DIR
// Make directory of user naam
// Stores directoryname in session
//$foldername = @$_SESSION[name];
$date = date("YmdHis");
if($foldername !== ""){
mkdir("../upload/" . $foldername . $date, 0700);
//echo "Folder " . $foldername . " was created!<br>";
}
$_SESSION['foldernaam'] = $foldername . $date;
// END MK DIR
/*
* Iterate over all received files.
*/
foreach($_FILES as $tagname=>$objekt)
{
// get the temporary name (e.g. /tmp/php34634.tmp)
$tempName = $objekt['tmp_name'];
// get the real filename
$realName = $objekt['name'];
// where to save the file?
$target = '../upload/' . $foldername . $date . '/' . $realName;
// print something to the user
echo "<br>Processing file $realName...\n";
flush();
// move the file to the target directory
move_uploaded_file($tempName,$target);
}
?>
From this moment on i have 2 sessions, there are some more pages in which i
email some thing to the user and to myself.
But in these first 3 lies my problem.
The strange thing is that i can recall user name, email and phonenumber in an later page,
but the string of the second session (filename and foldername) i cannot recall.
Where am i making a mistake, i've searched for some answer but at this moment
i'm completly stuck.