I'm usings sessions with an uploadhandler.php to create new directories with the "mkdir" command so I can direct user uploads to a specific folder. I am unsuccessful with the java uploader that I'm using.
I was successful with the following coding:
start.php
<?php
session_start();
$_SESSION['usuario'] = $loginUsername;
?>
<html>
<head><title>Christian County Video -- Easy Upload Start</title></head>
<body bgcolor=#CCCCCC background="../img/welcome.jpg" bgproperties="fixed" text="#000000" link="#0000EE" vlink="#551A8B">
<center>
<br><p><br>
<img src="../img/legal.bmp" border=1><br><p><br>
<form method=post action="uploadForm.php">
<table border=1 cellpadding=3 celspacing=3 align=center width=50%>
<tr><td colspan=2 align=center><?php if (isset($username)){if ($logout==false){if(isset($err)){echo "$err";}}}?></td></tr>
<tr><td align=center>All of the rights to the music and the pictures belong to you. <br> All we do is organize it, put it on DVD, and send it to you. <br> If you agree, please click below on "I Agree".</td><tr>
<tr><td align=center>Your Name: <input type=text name=username size="20"></td><tr>
<tr><td colspan=2 align=center><input type=submit value="I AGREE"></td><tr>
</table>
</form>
</body>
</html>
uploadForm.php
<?php
session_start();
$_SESSION['usuario'] = $username;
?>
<html>
<body>
<h1>Upload form</h1>
<form name="mainForm"
method="post"
enctype="multipart/form-data"
action="uploadHandler.php?test=y"
>
<input type="hidden" name="hiddenParameter" value="123">
<p>File: <input type="file" name="file"></p>
<p><input type="submit"></p>
</form>
</body>
</html>
uploadHandler.php
<?php
session_start();
//----------------------------------------------
// upload file handler script
//----------------------------------------------
//
// specify file parameter name
$file_param_name = 'file';
//
// retrieve uploaded file name
$file_name = $_FILES[ $file_param_name ][ 'name' ];
//
// retrieve uploaded file path (temporary stored by php engine)
$source_file_path = $_FILES[ $file_param_name ][ 'tmp_name' ];
//
// construct target file path (desired location of uploaded file) -
// here we put to the web server document root (i.e. '/home/wwwroot')
// using user supplied file name
if (file_exists("c:\\Server\\upload\\".$_SESSION['usuario'])) {
$target_file_path = "c:\\Server\\upload\\".$_SESSION['usuario']."\\".$file_name;
} else {
mkdir ("c:\\Server\\upload\\".$_SESSION['usuario']);
}
$target_file_path = "c:\\Server\\upload\\".$_SESSION['usuario']."\\".$file_name;
//
// move uploaded file
echo "Moving file " . $source_file_path . " > " . $target_file_path . ": ";
if( move_uploaded_file( $source_file_path, $target_file_path ) ) {
echo "success";
} else{
echo "failure";
}
//
// below is trace of variables
?>
<html>
<body>
<h1>GET content</h1>
<pre><?print_r( $_GET );?></pre>
<h1>POST content</h1>
<pre><?print_r( $_POST );?></pre>
<h1>FILES content</h1>
<pre><?print_r( $_FILES );?></pre>
</body>
The mkdir command works there. This is the test script. When I introduce the actual java upload applet though (which is supposed to accept cookies), the files still upload, but not to a newly created directory from the "mkdir" command. The following is the index.php that I replace the above uploadForm.php to access the java upload applet.
index.php
<?php
session_start();
$_SESSION['usuario'] = $username;
?>
<html>
<body bgcolor=#CCCCCC background="../img/welcome.jpg">
<center>
<applet name="jumpLoaderApplet"
code="jmaster.jumploader.app.JumpLoaderApplet.class"
archive="jumploader_z.jar"
width="750"
height="350"
mayscript>
<param name="gc_loggingLevel" value="DEBUG"/>
<param name="uc_uploadUrl" value="/Jumploader/uploadHandler.php"/>
<param name="uc_uploadThreadCount" value="1"/>
<param name="uc_maxFiles" value="-1"/>
<param name="uc_maxFileLength" value="-1"/>
<param name="uc_maxLength" value="-1"/>
<param name="uc_fileNamePattern" value=""/>
<param name="uc_directoriesEnabled" value="true"/>
<param name="uc_duplicateFileEnabled" value="false"/>
<param name="uc_fileParameterName" value="file"/>
<param name="uc_fileNamePolicy" value="name"/>
<param name="uc_logServerResponse" value="DEBUG"/>
<param name="uc_partitionLength" value="-1"/>
<param name="uc_userAgent" value=""/>
<param name="uc_cookie" value="PHPSESSID"/>
<param name="uc_useBrowserCookie" value="true"/>
<param name="vc_lookAndFeel" value="system"/>
<param name="vc_localFilesViewEnabled" value="true"/>
<param name="vc_addFilesActionEnabled" value="true"/>
<param name="vc_logoEnabled" value="true"/>
<param name="vc_logoUrl" value="http://youserver/yourfile.png"/>
<param name="vc_fileTreeShowFileLength" value="true"/>
<param name="vc_fileTreeUploadSplitLocationPercent" value="40"/>
<param name="ac_fireUploaderFileAdded" value="true"/>
<param name="ac_fireUploaderFileRemoved" value="false"/>
<param name="ac_fireUploaderFileStatusChanged" value="true"/>
<param name="ac_fireUploaderFilesReset" value="false"/>
<param name="ac_fireUploaderStatusChanged" value="true"/>
</applet>
</body>
</html>
Can anyone tell me what I'm doing wrong? I was told not to use a java upload applet, but I really like this one. For details on what the above parameters mean to the java applet go to http://www.jumploader.com/doc_appletconfig.html
Thankyou very much!
Ben Russell