Depends what you mean by file upload ... PHP does not manage the "input stream", all the work is done before by the webserver, so you can't catch any error at this point.
On Wed, Nov 4, 2009 at 8:10 AM, dziobacz <aaabbbcccda...@gmail.com> 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); > } > > > -- Thomas Rabaix http://rabaix.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -~----------~----~----~----~------~----~------~--~---