CURL PHP send files file extension error -


im trying send 2 file via curl api. seems work except api coming , saying file type not allowed. response is:

string(189)  {     "statusid": -1,     "success": false,     "returnobject": null,     "message": "please check file format of uploaded files. support .pdf .jpg, .png, .bmp , .gif file extensions. } 

as can see, api json response means can see there files thinks dont have extension. have looked @ absolute url of file , file extension , jpg or pdf. ideas?

here curl code:

 // send file curl_setopt($request, curlopt_post, true); curl_setopt(     $request,     curlopt_postfields,     array(         'clientid' => $client,       'file' =>           '@'.realpath(__dir__ . '/..').'/webroot/img/uploads/documents/'.$_files['image']['name'],        'file2' =>           '@'.realpath(__dir__ . '/..').'/webroot/img/uploads/documents/'.$_files['image1']['name']     )); curl_setopt(     $request, curlopt_httpheader, array(             "authentication: xxxxxxxxxxxxx",             "cache-control: no-cache",             "content-type: multipart/form-data;")); curl_setopt(     $request, curlopt_customrequest, "post");  // output response curl_setopt($request, curlopt_returntransfer, true); var_dump(curl_exec($request));  // close session curl_close($request); 

what api using?

without specific information have take wild guess: response api says

we support .pdf .jpg, .png, .bmp , .gif file extensions.

however, in question mention file extensions

are jpg or pdf.

maybe problem here files have upper case extensions, e.g. .jpg , .pdf, api accepts lower case extensions, e.g. .jpg , .pdf. file systems (e.g. fat or ntfs on windows) not care upper or lower case in file names, other file systems (e.g. ext4 on linux) care. try change extensions consist of lower case letters before send files api.

another guess file format, actual content of file, not 1 of file formats supported api. example, take text file foo.txt , rename foo.jpg. take care of extension, content of file still text , not jpeg image. maybe api check that, too.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -