Re: pear Uploader class issues
| From: | daniel | Date: | Fri, 24 May 2002 12:26:11 +0000 |
| Subject: | Re: pear Uploader class issues | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-6386@lists.php.net to get a copy of this message | ||
hi i still cant get this to work what is the problem ?
"Daniel" <daniel@electroteque.org> wrote in message
news:20020523122211.56030.qmail@pb1.pair.com...
> if (PEAR::isError($dest_name)) {
>
> if ($dest_name->getCode() == 'FILE_EXISTS') {
>
> // store for example the file in a tmp dir
>
> $dest_name = $file->moveTo($tmp_dir);
>
> } else {
>
> echo $file->errorCode();
>
> exit_msg($dest_name->getMessage(), $HTTP_REFERER, "Back");
>
> exit();
>
> }
>
> }
>
> here is my bit of code but it skips the first bit altogether
>
> "Tomas V.V.Cox" <cox@idecnet.com> wrote in message
> news:3CECDD85.B5262C72@idecnet.com...
> > daniel wrote:
> > >
> > > 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') {
> >
> > Do not forget to check first for a PEAR Error, there is the method:
> >
> > if (PEAR::isError($dest_name) &&
> > $dest_name->getCode() == 'FILE_EXISTS') {
> > //code
> > }
> >
> > Tomas V.V.Cox
> >
> > > "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
> > >
> > > --
> > > PEAR Development Mailing List (http://pear.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
>
>