Re: pear Uploader class issues
| From: | Tomas V.V.Cox | Date: | Thu, 23 May 2002 08:44:33 +0000 |
| Subject: | Re: pear Uploader class issues | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-6355@lists.php.net to get a copy of this message | ||
daniel wrote:
>
> hi i have some issues with the pear uploader class i'm trying to get
> specific error id's out of the script using
> $file->getProp('error') unfortunatly its not showing up or is returning null
> , how is it possible to get the errors out, i'll like to find which error it
> is and if its a FILE_EXISTS error i'd like to show a confirm box saying
> overwrite file and if click yes change the value of $dest_name =
> $file->moveTo($dest_dir,'false'); to true , how is this possible ?
>
I've commited a small patch to be able to retrieve error codes too. You
can patch your file manually, change line 184 to:
return PEAR::raiseError($this->errorCode($e_code), $e_code);
So you are able to do something like:
if ($step_upload) {
... // common upload code
$fname = $file->moveTo($dest);
if (PEAR::isError($fname)) {
if ($fname->getCode() == 'FILE_EXISTS') {
// store for example the file in a tmp dir
$fname = $file->moveTo($tmp_dest);
// show use confirm page with a link like:
// <a href="$PHP_SELF?step_confirm=1&file=$fname">..
} else {
die($fname->getMessage());
}
}
} elseif ($step_confirm) {
// Move from tmp to the upload dir
move("$tmp_dest/".basename($file), $dest);
}
Tomas V.V.Cox