protected function RestfulCreateEntityTestCase::uploadFile in RESTful 7
Uploads a file issuing a POST HTTP request.
1 call to RestfulCreateEntityTestCase::uploadFile()
- RestfulCreateEntityTestCase::testFileUploadAccess in tests/
RestfulCreateEntityTestCase.test - Test access for file upload.
File
- tests/
RestfulCreateEntityTestCase.test, line 215 - Contains RestfulCreateEntityTestCase
Class
- RestfulCreateEntityTestCase
- @file Contains RestfulCreateEntityTestCase
Code
protected function uploadFile() {
$value = '@' . $this->imagePath;
// PHP 5.5 introduced a CurlFile object that deprecates the old @filename
// syntax. See: https://wiki.php.net/rfc/curl-file-upload
if (function_exists('curl_file_create')) {
$value = curl_file_create($this->imagePath);
}
return $this
->httpRequest('api/file-upload', \RestfulInterface::POST, array(
'filename' => $value,
), array(
'Content-Type' => 'multipart/form-data',
), TRUE);
}