I have the following problem is that regardless of the error it only seens to return the value of $error==4?? there are multiple files being uploaded but i only want to retrn 1 message error 4 if no files have been uploaded and error 2 if a file is more than 204008b

foreach ($_FILES["fileatt"]["error"] as $key => $error) { 
if ($error == UPLOAD_ERR_OK)
{ 
$fileatt = $_FILES['fileatt']['tmp_name'][$key];
$fileatt_type = $_FILES['fileatt']['type'][$key];
$fileatt_name = $_FILES['fileatt']['name'][$key]; 
}
if ($error==4)
{
$action="reply";
$sideaction="";
$error ="You did not upload any file attachment do you still wish to proceed?";
}
if (($error==2) || ($error==4))
{
$action="reply";
$sideaction="addattachments";
$error ="An error occured, you can only upload files with a maximum filesize of 200KB please try again";
}
}

Hi

I don't know to much about PHP but I would use the variable like $errormsg instead of $error.

You set the value of $error = "You did not upload any file attachment do you still wish to proceed?" as long as $error is 4.

So if $error is 4 then the next if statement will not be carried out because it is no longer a number.

those are the last two $error statements in loop so they should not affect it

your two conditions. in first condition because when $error==4 then it will go to for first condition and if ($error==2) then why are you again checking for with OR operator

if ($error==4)

if ($error==2)

try this format

your two conditions. in first condition because when $error==4 then it will go to for first condition and if ($error==2) then why are you again checking for with OR operator

if ($error==4)

if ($error==2)

try this format

That say's it a bit better.

if (($error==2) || ($error==4))

The if (error == 4) part will never return true so it isn't needed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.