Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
File type empty in SendPOST #5548
I'm tried send file to my php server with codeception, using REST, so I try:
$I->sendPOST('/uploads/upload-file', ['idFile' => $idFile], ['file' => [ 'name' => 'sample_file.odt', 'type' => 'application/vnd.oasis.opendocument.text', 'error' => UPLOAD_ERR_OK, 'size' => filesize(codecept_data_dir('sample_file.odt')), 'tmp_name' => codecept_data_dir('sample_file.odt')]]);
The file arrives in $ _FILES, however there is a problem, the "type" property is empty, and from what I checked in the codeception code:
Even though I pass a value to "type" it is calling the function getFileType that uses the mime_content_type function, it may not be working well with .odt files.
What are you trying to achieve?
echo $_FILES['file']['type']; // => 'application/vnd.oasis.opendocument.text'
What do you get instead?
echo $_FILES['file']['type']; // => ''
actor: ApiTester modules: enabled: - REST: url: http://localhost:3000/my-server/api depends: PhpBrowser part: Json - Helper\Api - Asserts
Guzzle connector used by PhpBrowser ignores type field of file array: https://github.com/Codeception/Codeception/blob/3.0.1/src/Codeception/Lib/Connector/Guzzle.php#L300