zend framework2 - PDF is upload with application/octet-stream -
i have upload in application, user can upload pdf, png, jpg , gif files maximum file size of 2mb. when upload pdf larger size of 2mb error file has incorrect mimetype of 'application/octet-stream'
here can see filters validators:
'type' => 'zend\inputfilter\fileinput', 'name' => $name, 'required' => $required, 'filters' => array( array( 'name' => '\application\filter\file\renameupload', 'options' => array( 'target' => 'data/upload', 'use_upload_name' => true, 'count_up' => true, ), ), ), 'validators' => array( array('name' => '\zend\validator\file\uploadfile'), array( 'name' => '\zend\validator\file\extension', 'options' => array( 'extension' => array( 'pdf', 'jpg', 'jpeg', 'png', 'gif', ), ), ), array( 'name' => 'zend\validator\file\size', 'options' => array( 'max' => '2mb', 'min' => '1kb', ), ), array( 'name' => '\zend\validator\file\mimetype', 'options' => array( 'mimetype' => array( 'application/pdf', 'image/jpg', 'image/jpeg', 'image/png', 'image/gif', ), ), ), ),
the renameupload
own filter, checks if file same name exists , renames it, adding underscore number.
when add 'application/octet-stream' mimetype array upload works (with problem, file 2 times copied target directory)
anyone idea how can fix problem?
Comments
Post a Comment