2

I'm using PUT method to upload files using dropzone.js on frontend. However when I want to work with files both Symfony's Request object and $_FILES array are empty.

I have checked everything in this huge checklist and it did not help to me since it does not says anything about uploading via PUT method.

Community
  • 1
  • 1
Northys
  • 1,305
  • 3
  • 16
  • 32
  • Line one of the description from the [documentation](http://php.net/manual/en/reserved.variables.files.php). `An associative array of items uploaded to the current script via the **HTTP POST** method.` emphasis added. – Jonnix Nov 30 '16 at 14:14
  • I found it in the documentation and this is the reason why I replied to my own question. Link added in description for more information. – Northys Nov 30 '16 at 14:15
  • Possible duplicate of [Why would $\_FILES be empty when uploading files to PHP?](http://stackoverflow.com/questions/3586919/why-would-files-be-empty-when-uploading-files-to-php) – cske Nov 30 '16 at 14:18

1 Answers1

5

PHP does not convert files uploaded via PUT method into $_FILES hence Symfony`s Request object is empty too.

You need to handle incoming file using following code.

/* PUT data comes in on the stdin stream */
$putdata = fopen("php://input", "r");

Or using $request->getContent() in symfony.

PHP also supports PUT-method file uploads as used by Netscape Composer and W3C's Amaya clients. See the PUT Method Support for more details. http://php.net/manual/en/features.file-upload.post-method.php

Northys
  • 1,305
  • 3
  • 16
  • 32