what about returning the error the copy function would have thrown ? Thanks
----- Original Message ----- From: "John Nichel" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, July 28, 2004 3:00 PM Subject: Re: [PHP] How do I return the error > 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 > [EMAIL PROTECTED] > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php