Re: pear Uploader class issues
| From: | daniel | Date: | Thu, 23 May 2002 11:57:25 +0000 |
| Subject: | Re: pear Uploader class issues | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-6362@lists.php.net to get a copy of this message | ||
ok i made the patch and restarted there is no such function as getCode in
the class so its not getting anything ? did u mean errorCode ? it doesnt
seem to get anything doing
if ($dest_name->getCode() == 'FILE_EXISTS') {
"Tomas V.V.Cox" <cox@idecnet.com> wrote in message
news:3CECABF1.DE3F4861@idecnet.com...
> 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