uploading a variable number of files
Posted: Mon Sep 13, 2010 12:40 pm
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
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