Rectangle 27 0

  • Update apigility with composer. File upload is working in version 1.0.3
  • Use Postman to send files but with no headers.Just select form-data.It worked for me.
  • To move uploaded file use rename instead of move_uploaded_file.

php - Apigility file upload - Stack Overflow

php zend-framework2 apigility
Rectangle 27 0

  • Update apigility with composer. File upload is working in version 1.0.3
  • Use Postman to send files but with no headers.Just select form-data.It worked for me.
  • To move uploaded file use rename instead of move_uploaded_file.

php - Apigility file upload - Stack Overflow

php zend-framework2 apigility
Rectangle 27 0

For those who aren't aware, Apigility is a Zend Framework 2 based framework specifically made for Rest/Rpc API's.

To do file uploads, please refer to their documentation on the recent updates as noted by Jon Day.

How can you allow uploading files via your API?

Zend Framework 2 provides a variety of classes surrounding file upload functionality, including a set of validators (used to validate whether the file was uploaded, as well as whether it meets specific criteria such as file size, extension, MIME type, etc.), a set of filters (used to allow renaming an uploaded file, as well as, more rarely, to manipulate the contents of the file), and file-upload-specific inputs for input filters (because validation of files needs to follow different rules than regular data).

Currently the limitation is that Apigility will only accept multipart/form-data

Using Xdebug I am getting the following out :

$data_array = $inputFilter->getValues();
$image = $data_array['images_data'];

The $image array looks like this :

name = MemeCenter_1400658513231_337.jpg
   type = image/jpeg
   tmp_name = /tmp/phpzV3mWA
   error = 0
   size = 379580

php - Apigility file upload - Stack Overflow

php zend-framework2 apigility
Rectangle 27 0

For those who aren't aware, Apigility is a Zend Framework 2 based framework specifically made for Rest/Rpc API's.

To do file uploads, please refer to their documentation on the recent updates as noted by Jon Day.

How can you allow uploading files via your API?

Zend Framework 2 provides a variety of classes surrounding file upload functionality, including a set of validators (used to validate whether the file was uploaded, as well as whether it meets specific criteria such as file size, extension, MIME type, etc.), a set of filters (used to allow renaming an uploaded file, as well as, more rarely, to manipulate the contents of the file), and file-upload-specific inputs for input filters (because validation of files needs to follow different rules than regular data).

Currently the limitation is that Apigility will only accept multipart/form-data

Using Xdebug I am getting the following out :

$data_array = $inputFilter->getValues();
$image = $data_array['images_data'];

The $image array looks like this :

name = MemeCenter_1400658513231_337.jpg
   type = image/jpeg
   tmp_name = /tmp/phpzV3mWA
   error = 0
   size = 379580

php - Apigility file upload - Stack Overflow

php zend-framework2 apigility
Rectangle 27 0

You can use the option ('magicFile' => false) for the MimeType validator which fixes the problem without any modification at the zf library.

php - Apigility file upload - Stack Overflow

php zend-framework2 apigility
Rectangle 27 0

You can use the option ('magicFile' => false) for the MimeType validator which fixes the problem without any modification at the zf library.

php - Apigility file upload - Stack Overflow

php zend-framework2 apigility