Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple file upload+function

Status
Not open for further replies.

kusarigama

Technical User
Apr 24, 2002
45
DE
Hi, all

I have a problem, that i have 3 userfile fields which i want to parse to a function. All works - but only if i start with the first one. When I start with the second, than no file of those 3 will be uploaded.

here is a snippet of my code:

HTML stuff ...

<input name=userfile[] type=file> // 1.file
<input name=userfile[] type=file> // 2.file
<input name=userfile[] type=file> // 3.file


PHP stuff ...

if(..something)
{
folder_check($userfile_name[0]);
}

// my function which creates folder on the server and put the uploaded files in :). Files only be copied when the file field is set ...

function folder_check($file_confirm)
{
global $HTTP_POST_VARS;
array_pop($HTTP_POST_VARS);
global $foldertrack, $destfolder, $userfile, $userfile_name, $success, $problem, $loc;
global $REQUIRED, $additional_headers, $body_of_email, $recipient, $subject, $loc, $sub_success;
if($file_confirm)
{
$fp = fopen($foldertrack,&quot;r&quot;);
$counter = intval(fread($fp ,filesize($foldertrack)));
fclose($fp);
clearstatcache();
$counter++;
$fp = fopen($foldertrack,&quot;w&quot;);
fputs($fp ,$counter);
fclose($fp);
$destination = &quot;$destfolder$counter/&quot;;
mkdir(&quot;$destination&quot;, 0755);
//-------------------------------------------------------
while(list($key) = each($userfile))
{
if($userfile_name[$key] == &quot;&quot;)
{
continue;
}
else
{
$pic_count++;
}
$replacer = ereg_replace (&quot; &quot;, &quot;_&quot;, $userfile_name[$key]);

$check = copy($userfile[$key],$destination.$replacer);
print $check ? $success : $problem;
$body_of_email .= &quot;Picture $pic_count: $loc$destination$replacer\n\n&quot;;
}
}

Thnx in advance

Olli

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top