Hi, Wednesday, July 28, 2004, 11:56:16 PM, you wrote: MO> Hi I have this function below - if it reurns false I want to MO> also return the error so I can print it in my calling function. MO> Can I do this?
MO> Cheers MO> Matt MO> function fileUpload($file) { MO> if ($file['type'] == "image/gif" || $file['type'] == "image/pjpeg"){ MO> if (@copy ($file['tmp_name'], "images/" . $file['name'])) MO> return true; MO> }else { MO> return false; MO> } MO> } You can always return an array() something like this: function fileUpload($file) { $r = array(false,''); switch($file['error']){ case UPLOAD_ERR_INI_SIZE: $r[1] = 'The uploaded file exceeds the upload_max_filesize directive in php.ini.'; break; case UPLOAD_ERR_FORM_SIZE: $r[1] = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'; break; case UPLOAD_ERR_PARTIAL: $r[1] = 'The uploaded file was only partially uploaded.'; break; case UPLOAD_ERR_NO_FILE: $r[1] = 'No file was uploaded'; break; default: if ($file['type'] == "image/gif" || $file['type'] == "image/pjpeg"){ if (@copy ($file['tmp_name'], "images/" . $file['name'])) $r[0] = true; else $r[1] = 'Could not copy the file.'; }else { $r[1] = 'The uploaded file is not the right type.'; } break; } return $r; } list ($status, $error) = fileUpload($file); if(!$status) echo $error; -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php