kusarigama
Technical User
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,"r"
$counter = intval(fread($fp ,filesize($foldertrack)));
fclose($fp);
clearstatcache();
$counter++;
$fp = fopen($foldertrack,"w"
fputs($fp ,$counter);
fclose($fp);
$destination = "$destfolder$counter/";
mkdir("$destination", 0755);
//-------------------------------------------------------
while(list($key) = each($userfile))
{
if($userfile_name[$key] == ""
{
continue;
}
else
{
$pic_count++;
}
$replacer = ereg_replace (" ", "_", $userfile_name[$key]);
$check = copy($userfile[$key],$destination.$replacer);
print $check ? $success : $problem;
$body_of_email .= "Picture $pic_count: $loc$destination$replacer\n\n";
}
}
Thnx in advance
Olli
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,"r"
$counter = intval(fread($fp ,filesize($foldertrack)));
fclose($fp);
clearstatcache();
$counter++;
$fp = fopen($foldertrack,"w"
fputs($fp ,$counter);
fclose($fp);
$destination = "$destfolder$counter/";
mkdir("$destination", 0755);
//-------------------------------------------------------
while(list($key) = each($userfile))
{
if($userfile_name[$key] == ""
{
continue;
}
else
{
$pic_count++;
}
$replacer = ereg_replace (" ", "_", $userfile_name[$key]);
$check = copy($userfile[$key],$destination.$replacer);
print $check ? $success : $problem;
$body_of_email .= "Picture $pic_count: $loc$destination$replacer\n\n";
}
}
Thnx in advance
Olli