Featured post
php - sfValidatorFile 'mime_type' validation not working in production server -
i've built backend couple of models, 1 of them, products, supports image uploading. locally file uploading works fine. when did deploy, stopped working: form validation fails because of wrong mime type (error is: "invalid mime type (jpeg image data, exif standard).") image field, when i'm using same jpg image used test locally.
i'll show form class code:
class productform extends baseproductform { public function configure() { ... /* widgets */ ... $this->widgetschema['image_1'] = new sfwidgetforminputfileeditable(array( 'file_src' => '/'.basename(sfconfig::get('sf_upload_dir')).'/products/normal_'.$this->getobject()->getimage_1(), 'is_image' => true, 'edit_mode' => strlen($this->getobject()->getimage_1()) > 0, 'delete_label' => 'remover el archivo actual', 'template' => '<div>%file%<br />%input%</div>' )); ... /* validators */ $this->validatorschema['image_1'] = new sfvalidatorfileimage(array( 'required' => (! $this->getobject()->getimage_1()), 'max_size' => '5252880', 'path' => sfconfig::get('sf_upload_dir').'/products/original', 'mime_types' => 'web_images', 'min_width' => 470, 'max_width' => 99999, 'min_height' => 306, 'max_height' => 99999, 'validated_file_class' => 'sfresizedfile', // class creates thumbnails ), array( 'required' => 'tenés que seleccionar una imagen principal.', 'max_size' => 'el tamaño máximo es 5 mb', //'mime_types' => 'sólo se permiten imágenes para web (jpg, png, gif)', 'invalid_image' => '%value% no es un archivo de imagen.', 'min_width' => 'el ancho de "%value%" es muy chico (mínimo %min_width% pixels).', 'min_height' => 'el alto de "%value%" es muy chico (mínimo %min_height% pixels).', )); $this->validatorschema['image_1_delete'] = new sfvalidatorpass(); ... } ...
sfvalidatorfileimage custom validator class extends sfvalidatorfile size checks. i've tried regular sfvalidatorfile class in case, error persists. mime types have server configuration? , why break on regular web server?
speed in answer appreciated since needed deployed today.
the solution find commenting first item in array of "mime_type_guessers" option of sfvalidatorfile class, 1 reads "guessfromfileinfo", specifically. here code:
(lib/vendor/symfony/lib/validator/sfvalidatorfile.class.php - line 62 aprox.)
$this->addoption('mime_type_guessers', array( //array($this, 'guessfromfileinfo'), array($this, 'guessfrommimecontenttype'), array($this, 'guessfromfilebinary'), ));
also, copying file lib/ , commenting line in file didn't worked, symfony did used 1 in lib/vendor/symfony/lib/ did change there.
- Get link
- X
- Other Apps
Comments
Post a Comment