stephmck990
03-13-2009, 03:50 PM
Okay, so you guys had answered my question on how to do this on a single file, but now I need some help with doing it on multiple uploaded files.
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form action="multiple_upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td width="100%">
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<label><font size="1">Please enter your name, last name first, separated
by an underscore and number photo correctly. (ex. Smith_John):</font></label>
<br />
<input name="lastname" type="text" id="lastname" size="25">
</font></td>
</tr>
<tr>
<td> <input name="ufile[]" type="file" id="ufile[]" size="25" /></td>
</tr>
<tr>
<td> <input name="ufile[]" type="file" id="ufile[]" size="25" /></td>
</tr>
<tr>
<td> <input name="ufile[]" type="file" id="ufile[]" size="25" /></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Upload Photos" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
And...
<?php
$path1= "uploads/".$HTTP_POST_FILES['ufile']['name'][0];
$path2= "uploads/".$HTTP_POST_FILES['ufile']['name'][1];
$path3= "uploads/".$HTTP_POST_FILES['ufile']['name'][2];
$target_path = $target_path . rawurlencode( $_POST['lastname']);
copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);
copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2);
copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3);
echo "File Name :".$HTTP_POST_FILES['ufile']['name'][0]."<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size'][0]."<BR/>";
echo "File Type :".$HTTP_POST_FILES['ufile']['type'][0]."<BR/>";
echo "<img src=\"$path1\" width=\"75\" height=\"75\">";
echo "<P>";
echo "File Name :".$HTTP_POST_FILES['ufile']['name'][1]."<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size'][1]."<BR/>";
echo "File Type :".$HTTP_POST_FILES['ufile']['type'][1]."<BR/>";
echo "<img src=\"$path2\" width=\"75\" height=\"75\">";
echo "<P>";
echo "File Name :".$HTTP_POST_FILES['ufile']['name'][2]."<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size'][2]."<BR/>";
echo "File Type :".$HTTP_POST_FILES['ufile']['type'][2]."<BR/>";
echo "<img src=\"$path3\" width=\"75\" height=\"75\">";
$filesize1=$HTTP_POST_FILES['ufile']['size'][0];
$filesize2=$HTTP_POST_FILES['ufile']['size'][1];
$filesize3=$HTTP_POST_FILES['ufile']['size'][2];
if($filesize1 && $filesize2 && $filesize3 != 0)
{
echo "<P>We have recieved your files";
}
else {
echo "ERROR.....";
}
if($filesize1==0) {
echo "There is an error with your first file";
echo "<BR />";
}
if($filesize2==0) {
echo "There is an error with your second file";
echo "<BR />";
}
if($filesize3==0) {
echo "There is an error with your third file";
echo "<BR />";
}
?>
Is there any way to take the text typed into the 'lastname' textbox and rename the uploaded files to have their last name at the beginning of the file names?
Thanks in advance. :)
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<form action="multiple_upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
<td width="100%">
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<label><font size="1">Please enter your name, last name first, separated
by an underscore and number photo correctly. (ex. Smith_John):</font></label>
<br />
<input name="lastname" type="text" id="lastname" size="25">
</font></td>
</tr>
<tr>
<td> <input name="ufile[]" type="file" id="ufile[]" size="25" /></td>
</tr>
<tr>
<td> <input name="ufile[]" type="file" id="ufile[]" size="25" /></td>
</tr>
<tr>
<td> <input name="ufile[]" type="file" id="ufile[]" size="25" /></td>
</tr>
<tr>
<td align="center"><input type="submit" name="Submit" value="Upload Photos" /></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
And...
<?php
$path1= "uploads/".$HTTP_POST_FILES['ufile']['name'][0];
$path2= "uploads/".$HTTP_POST_FILES['ufile']['name'][1];
$path3= "uploads/".$HTTP_POST_FILES['ufile']['name'][2];
$target_path = $target_path . rawurlencode( $_POST['lastname']);
copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1);
copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2);
copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3);
echo "File Name :".$HTTP_POST_FILES['ufile']['name'][0]."<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size'][0]."<BR/>";
echo "File Type :".$HTTP_POST_FILES['ufile']['type'][0]."<BR/>";
echo "<img src=\"$path1\" width=\"75\" height=\"75\">";
echo "<P>";
echo "File Name :".$HTTP_POST_FILES['ufile']['name'][1]."<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size'][1]."<BR/>";
echo "File Type :".$HTTP_POST_FILES['ufile']['type'][1]."<BR/>";
echo "<img src=\"$path2\" width=\"75\" height=\"75\">";
echo "<P>";
echo "File Name :".$HTTP_POST_FILES['ufile']['name'][2]."<BR/>";
echo "File Size :".$HTTP_POST_FILES['ufile']['size'][2]."<BR/>";
echo "File Type :".$HTTP_POST_FILES['ufile']['type'][2]."<BR/>";
echo "<img src=\"$path3\" width=\"75\" height=\"75\">";
$filesize1=$HTTP_POST_FILES['ufile']['size'][0];
$filesize2=$HTTP_POST_FILES['ufile']['size'][1];
$filesize3=$HTTP_POST_FILES['ufile']['size'][2];
if($filesize1 && $filesize2 && $filesize3 != 0)
{
echo "<P>We have recieved your files";
}
else {
echo "ERROR.....";
}
if($filesize1==0) {
echo "There is an error with your first file";
echo "<BR />";
}
if($filesize2==0) {
echo "There is an error with your second file";
echo "<BR />";
}
if($filesize3==0) {
echo "There is an error with your third file";
echo "<BR />";
}
?>
Is there any way to take the text typed into the 'lastname' textbox and rename the uploaded files to have their last name at the beginning of the file names?
Thanks in advance. :)