Re: How do I return the error
| From: | John Nichel | Date: | Wed, 28 Jul 2004 14:00:47 +0000 |
| Subject: | Re: How do I return the error | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-192096@lists.php.net to get a copy of this message | ||
Matthew Oatham wrote:
Hi I have this function below - if it reurns false I want to also return the error so I can print it in my calling function. Can I do this?
Cheers
Matt
function fileUpload($file) {
if ($file['type'] == "image/gif" || $file['type'] == "image/pjpeg"){ if (@copy ($file['tmp_name'], "images/" . $file['name']))
return true;
}else { return false;
}
}
$error = "";
function fileUpload($file) {
global $error;
if ($file['type'] == "image/gif" || $file['type'] == "image/pjpeg"){
if (@copy ($file['tmp_name'], "images/" . $file['name']))
return true;
}else {
$error = "Something went wrong";
return false;
}
}
if ( ! fileUpload ( $file ) ) {
echo ( $error );
}
Course, there are numerous other ways of doing this. I persoanlly use two custom functions to handle/display errors.
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john@kegworks.com