Symfony - Form File Upload [temp to another server using ftp]
Friday, May 25, 2012
class PhotoForm extends BasePhotoForm
{
public function configure()
{
$this->setWidgets(array(
'photo' => new sfWidgetFormInputFile(array('label' => 'Зураг')),
));
$this->setValidators(array(
'photo' => new sfValidatorFile(
array(
'required' => false,
'max_size' => 5242880,
'path' => sfConfig::get('sf_upload_dir'),
'mime_types' => array(
'image/jpeg',
'image/pjpeg',
'image/png',
'image/x-png',
'image/gif',
),
'validated_file_class' => 'sfValidatedFileLocations'
),
array(
'required' => 'Та зураг оруулна уу',
'max_size' => 'Таны оруулсан зурагны хэмжээ иx байна. Хамгийн иxдээ 5MB.',
'mime_types' => 'Та зөвxөн зурган файл оруулаx боломжтой')),
));
$this->widgetSchema['photo'] = new sfWidgetFormInputFileEditable(array(
'label' => 'Зураг',
'file_src' => FtpHandler::FTPFOLDER . 'files/' . $this->getObject()->getPhoto(),
'is_image' => true,
'edit_mode' => !$this->isNew(),
), array('width' => 500));
$this->widgetSchema->setNameFormat('photo[%s]');
}
}