oh thx - so sfValidatorFile automatically catch partial, can't write etc. errors - thx
On 4 Lis, 08:21, Damien Alexandre <[email protected]> wrote: > You can, > but the way to handle file upload routine checks is to use > thehttp://www.symfony-project.org/api/1_2/sfValidatorFilein your form. > > Bye > > > > On Wed, Nov 4, 2009 at 8:10 AM, dziobacz <[email protected]> wrote: > > > I didn't find article about catching errors which can be during upload > > file in Symfony - can I do something like that below using try - > > catch ? Is it a good solution when something during file upload will > > go wrong ? > > > $unique_code = md5(uniqid(mt_rand())); > > $file = $this->form->getValue('photo'); > > $extension = $file->getExtension($file->getOriginalExtension()); > > $name_photo = $unique_code.$extension; > > > try > > { > > > $thumbnail1 = new sfThumbnail(700, 700, true, > > false); > > $thumbnail1->loadFile($file->getTempName()); > > $thumbnail1->save(sfConfig::get('sf_upload_dir'). > > DIRECTORY_SEPARATOR .$name_photo); > > > $record = new Photo(); > > $record->date_add = date("Y-m-d H:i:s"); > > $record->photo = $name_photo; > > $record->save(); > > } > > catch(Exception $e) > > { > > if > > (file_exists(sfConfig::get('sf_upload_dir').'/'.$name_photo)) > > unlink(sfConfig::get('sf_upload_dir').'/'.$name_photo); > > } > > -- > Damien ALEXANDREhttp://www.clever-age.com > Clever Age - Digital Architecture > Clever Garden - Digital Landscape > Tél: +33 1 53 34 66 10 GSM: +33 6 07 91 58 03 > Fax : +33 1 53 34 65 20 > > Clever Age vous invite à ses > petits-déjeunershttp://www.clever-age.com/actualites/petits-dejeuners/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---
