foreach ($attachmentFile->allAsArray() as $attachmentTestArray) { if (strtoupper($attachmentTestArray['attachmentURL']) == strtoupper($uploadAttachment)) { $exists++; } } echo $exists; break; //perform actual upload for attachments (4th tab) //perform actual upload for attachments (4th tab) case 'uploadAttachment': $documentName = basename($_FILES['myfile']['name']); $target_path = "attachments/" . basename($_FILES['myfile']['name']); $attachmentFile = new AttachmentFile(); $exists = 0; //loop through existing log attachments to verify that this name isn't already taken foreach ($attachmentFile->allAsArray() as $attachmentTestArray) { if (strtoupper($attachmentTestArray['attachmentURL']) == strtoupper($documentName)) { $exists++; } } //if match was not found //note, echoes are not being sent anywhere if ($exists == 0) { if (move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) { //set to web rwx, everyone else rw //this way we can edit the document directly on the server chmod($target_path, 0766); echo "success uploading!"; } else { header('HTTP/1.1 500 Internal Server Error'); echo "<div id=\"error\">There was a problem saving your file to {$target_path}.</div>";