my whole objective is to create a sub-folder within my upload folder, based on their first name and last name. so that they can upload files onto "their own" folder, easy for me to manage.
probably my logic is wrong.. since i'm not a "real" programmer 😛
anyway, my first page is to get users' first and last name.
form.php
<?php
// This is form.php
?>
<html>
<head><title>Photos Upload</title></head>
<body>
<center><p><br><br>
<form method="post" action="fl_name.php">
Please enter your First Name: <input type="text" name="firstName" />
<p>
Please enter your Last Name: <input type="text" name="lastName" /><p>
<input type="submit" value="Submit" />
</form>
</center>
</body>
</html>
form.php is working to my expectation. it gathers the input of first name and last name.
second, form.php sends info to fl_name.php
<?php
// this starts the session
session_start();
$firstname = $_POST['firstName'];
$lastname = $_POST['lastName'];
$fdate = date("Ymd_H:i:s", time());
$path = $fdate . "_" . $firstname . "_" . $lastname;
// this sets variables in the session
$_SESSION['fpath'] = $path;
if ($firstname == '') {
echo "<center><p>Please enter your first name.";
echo "<p><FORM METHOD='LINK' ACTION='form.php'><INPUT TYPE='submit' VALUE='Back'></FORM></center>";
} elseif ($lastname == '') {
echo "<center><p>Please enter your last name.";
echo "<p><FORM METHOD='LINK' ACTION='form.php'><INPUT TYPE='submit' VALUE='Back'></FORM></center>";
} else {
$oldumask = umask(0);
$cf = @mkdir("chenup/" . $path,0777);
umask($oldumask);
if ($cf) {
echo "<center><p>Please click <FORM METHOD='LINK' ACTION='upload.php'><INPUT TYPE='submit' VALUE='Continue'></FORM></center>";
// check session variable
echo "Dir is " . $_SESSION['fpath'];
} else {
echo "<center><p>An error has occurred while attempting to validate your name. ";
echo "<p>Please click <FORM METHOD='LINK' ACTION='form.php'><INPUT TYPE='submit' VALUE='Back'></FORM> to re-enter your name again.</center>";
}
}
?>
fl_name.php is working, since it manages to create directory and display the session variable - fpath
third, is the upload.php
<?php
// this starts the session
session_start();
require('includes/application_top.php');
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?> - Upload Photos</title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body>
<center>
<table border="0" width="100%" height="410" cellspacing="0" cellpadding="0" class="infoBox" width="660">
<tr class="infoBoxContents"><td class="main" align=center><p><br>
<?php
$numuploads = 5;
$count = 1;
?>
<form enctype="multipart/form-data" action="upload_process.php" method="post">
<?php
while ($count <= $numuploads)
{
?>
Image <?php echo $count; ?> <input name="userfile[]" type="file" /><br />
<?php
$count = $count + 1;
}
?>
<br>
<input type="submit" value="Upload" />
</td></tr>
<tr class="infoBoxContents">
<td class="main" align="center">
<table border="0" width="80%" cellspacing="0" cellpadding="0" class="infoBox"><tr class="infoBoxContents"><td class="main" align="left">
<p><br><ul><li>You can upload five (5) files at one time.
<li>Please bear in mind that uploading of large size files will be slow. It is dependant on your internet connection.
<li>Please rename your photos based on your firstname & lastname followed by a sequential number starting at 1. (Eg: benjohnson1.jpg, benjohnson2.jpg, etc)
<li>Upload only in <b>jpg</b>, <b>gif</b>, <b>png</b>, <b>tif</b> or <b>pdf</b> format. Other file extentions will not be accepted.
<li>Size: Maximum file size per photo is <b>10MB</b> (10,000KB).
<li>Photo Resolution: The bigger the resolution of the photo, the better printout quality you will get.</ul>
<li><?php echo "Dir is " . $_SESSION['fpath']; ?>
<center>Please refer to <a href="http://www.microsoft.com/windowsxp/using/digitalphotography/learnmore/bestquality.mspx" target="_blank">http://www.microsoft.com/windowsxp/using/digitalphotography/learnmore/bestquality.mspx</a></center>
</td></tr></table>
</td>
</tr>
<tr class="infoBoxContents">
<td class="main" align="center">
<p><br><img src="images/store_logo.png" alt="PicsWorld">
<br><font size=1>Copyright © 2008 <a href="http://picsworld.biz/">PicsWorld</a></font>
</td></tr></table>
</form></center></body></html>
upload.php is working as well, i mean, it still prints out the correct session variable
when i click upload, it goes to upload_process.php and shows error page. but if i'm not using session, everything is fine.