Hi! I need help. I try to attach the file to ajax request. but on the backend i can’t access it.$this->request->getUploadedFiles()
is empty. But $_FILES i can get all necessary information.
How does it???
Hi! I need help. I try to attach the file to ajax request. but on the backend i can’t access it.$this->request->getUploadedFiles()
is empty. But $_FILES i can get all necessary information.
How does it???
What Content-Type header are you sending with your request?
I have a separate property ContentType property: with a value of false; Whether to insert ContentType in headers???
I can’t remember details right now, but I believe there’s some specific header that comes with the POST request that a Cake form with 'type' => 'file'
generates, which controls whether or not it parses $_FILES
. Hopefully this will help, or someone else can jump in with the specifics.
Try whole name space:
Uploaded files can also be accessed as objects separately from the request data via the
Cake\Http\ServerRequest::getUploadedFile()
andCake\Http\ServerRequest::getUploadedFiles()
methods. These methods will always return objects, irrespectively of theApp.uploadedFilesAsObjects
configuration.
Scroll down a little. But I just use $_FILES also.