Try having two loops. First, you check to see if any files succeeded. If they did, decide you don't care about whether any didn't.
Then, second loop only if no files succeeded, then try and determine why they didn't.
Only one downside, if some files succeed and others fail, you won't have any response.
$error = ($_FILES["fileatt"]["error"]);
$errorcode = true;
for ($i=0; $i<count($error); $i++)
{
if ($error[$i] == UPLOAD_ERR_OK)
{
$errorcode = false;
}
}
if ($errorcode ==false)
{
$fileatt_name = $_FILES['fileatt']['name'];
$attachments1 = stripslashes($fileatt_name[0]);
$attachments2 = stripslashes($fileatt_name[1]);
$attachments3 = stripslashes($fileatt_name[2]);
$attachments4 = stripslashes($fileatt_name[3]);
}
else
{
for ($i=0; $i<count($error); $i++)
{
if ($error[$i] == 4)
{
$action="reply";
$sideaction="";
$error ="You did not upload any file attachment do you still wish to proceed?";
}
if ($error[$i] == 2)
{
$action="reply";
$sideaction="addattachments";
$error ="An error occured, you can only upload files with a maximum filesize of 200KB please try again";
}
}