Hello all;
I have a form with a variable amount of upload controls on it. (the names of the objects are license1upload1, license1upload2, license2upload1, etc) I am able to create a form with one upload control and upload the file without a problem(without using variable names)... however when I throw the variables in the loop thats where the problem starts! here is what I have the problem with:
****************************************************
FOR($x=1; $x<=$max_num_licenses; $x++)
{
FOR($y=1; $y<=$max_num_license_transcripts; $y++)
{
$thisfilename = "license".$x."upload".$y;
if (($_FILES[$thisfilename]["type"] == "application/msword")
|| ($_FILES[$thisfilename]["type"] == "text/plain")
|| ($_FILES[$thisfilename]["type"] == "application/pdf" )
|| ($_FILES[$thisfilename]["type"] == "text/richtext" )
&& ($_FILES[$thisfilename]["size"] < 2048)) //2mb
{
$upload_file_name = "l_".$_SESSION['ssn'].'_'.$x.'_'.$y.substr($_FILES[$thisfilename]["name"], -4);
move_uploaded_file($_FILES[$thisfilename]["tmp_name"],"C:/inetpub/wwwroot/uploadedfiles/" . $upload_file_name);
}
}
}
******************************************************************
could the problem be with passing the variable $thisfilename ?? if so, how should I pass the variable? being that the code is in php, I didnt think that I needed to use the <?php ?> to pass the value... im lost, any help out there?
Thanks in advance
uploading a variable number of files
Moderator: General Moderators
Re: uploading a variable number of files
you haven't stated what the actual problem is. Any error messages?
Re: uploading a variable number of files
sorry about that... the problem is that when I do select a file to upload, nothing happens when the form is processed. I can select the same file to upload using a form that has an upload control which doesnt use any variables in the name or ID for the object and it uploads without a problem.
Re: uploading a variable number of files
this is the code from the initial form where the actual object is created:
for($current_certificate=1; $current_certificate<=$_SESSION['actual_licenses']; $current_certificate++)
{
ECHO "<table border='0' align='center' bordercolor='#336699' cellpadding='2' cellspacing='2'>";
ECHO "<tr><td align='right'><b>Title: </b></td><td>".$_SESSION['license'.$current_certificate.'_title']."</td>";
ECHO "<td align='right'><b>State: </b></td><td>".$_SESSION['license'.$current_certificate.'_state']."</td>";
ECHO "<tr><td align='right'><b>ID #: </b></td><td>".$_SESSION['license'.$current_certificate.'_idnum']."</td>";
ECHO "<td align='right'><b>Issue Date: </b></td><td>".$_SESSION['license'.$current_certificate.'_issuedate']."</td>";
ECHO "<td align='right'><b> Exp. Date: </b></td><td>"
.$_SESSION['license'.$current_certificate.'_expdate']."</td></tr>";
ECHO '<br /><br /><table align="center"><td colspan="4" align="center">';
for ($WhichLicense=1; $WhichLicense<=$max_num_degree_transcripts; $WhichLicense++) {
echo '<div id="license'.$current_certificate.'upload'.$WhichLicense.'" style="display:';
if ($WhichLicense > 1) echo 'none';
else echo 'block';
echo '">';
ECHO '<input type="file" name="license'.$current_certificate.'upload'.$WhichLicense.'" id="license'.$current_certificate.'upload'.$WhichLicense.'"/></td>';
ECHO '</div>';
}
ECHO '<td colspan="4"><a href="javascript:addAnotherLicenseTranscript'.$current_certificate.'();" class="addlink" title="Upload more Transcripts">Upload another Transcript</a></td>';
echo "</table></div><br /><br /><br />" ;
}
for($current_certificate=1; $current_certificate<=$_SESSION['actual_licenses']; $current_certificate++)
{
ECHO "<table border='0' align='center' bordercolor='#336699' cellpadding='2' cellspacing='2'>";
ECHO "<tr><td align='right'><b>Title: </b></td><td>".$_SESSION['license'.$current_certificate.'_title']."</td>";
ECHO "<td align='right'><b>State: </b></td><td>".$_SESSION['license'.$current_certificate.'_state']."</td>";
ECHO "<tr><td align='right'><b>ID #: </b></td><td>".$_SESSION['license'.$current_certificate.'_idnum']."</td>";
ECHO "<td align='right'><b>Issue Date: </b></td><td>".$_SESSION['license'.$current_certificate.'_issuedate']."</td>";
ECHO "<td align='right'><b> Exp. Date: </b></td><td>"
.$_SESSION['license'.$current_certificate.'_expdate']."</td></tr>";
ECHO '<br /><br /><table align="center"><td colspan="4" align="center">';
for ($WhichLicense=1; $WhichLicense<=$max_num_degree_transcripts; $WhichLicense++) {
echo '<div id="license'.$current_certificate.'upload'.$WhichLicense.'" style="display:';
if ($WhichLicense > 1) echo 'none';
else echo 'block';
echo '">';
ECHO '<input type="file" name="license'.$current_certificate.'upload'.$WhichLicense.'" id="license'.$current_certificate.'upload'.$WhichLicense.'"/></td>';
ECHO '</div>';
}
ECHO '<td colspan="4"><a href="javascript:addAnotherLicenseTranscript'.$current_certificate.'();" class="addlink" title="Upload more Transcripts">Upload another Transcript</a></td>';
echo "</table></div><br /><br /><br />" ;
}