Hey Everyone,
I'm getting a "Couldn't open file" error when trying to upload a file to a custom module in zoho. I tested this yesterday and it worked fine however when testing today it doesn't work. I haven't changed the code so I'm not sure what the deal is. If anyone has any insight on this I would greatly appreciate it. Been testing and debugging this for hours..
- $FileName = $_FILES['File']['name'];
- $FileSize = $_FILES['File']['size'];
- $FileTmp = $_FILES['File']['tmp_name'];
- $FileType = $_FILES['File']['type'];
- $postFields = array("id"=>$AgentId[0], "content"=>curl_file_create($FileName,"application/pdf",basename($FileName)));
- echo "Filename: " . $FileName . "<br>" . "FileSize: " . $FileSize . "<br>" . "FileTmp: " . $FileTmp . "<br>" . "FileType: " . $FileType;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_VERBOSE, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_URL, "https://crm.zoho.com/crm/private/xml/CustomModule10/uploadFile?authtoken=--myauth--&scope=crmapi");
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
- $response = curl_exec($ch);
- echo curl_getinfo($ch) . '<br/>';
- echo curl_errno($ch) . '<br/>';
- echo curl_error($ch) . '<br/>';
- echo $response;
- curl_close($ch);
- if (!function_exists('curl_file_create')) {
- function curl_file_create($FileName, $mimetype = '', $postname = '') {
- return "@$FileName;filename="
- . ($postname ?: basename($FileName))
- . ($mimetype ? ";type=$mimetype" : '');
- }
- }
Response from website:
Filename: Scope.pdf
FileSize: 539651
FileTmp: /tmp/phpxyCcQS
FileType: application/pdf
Error Code(26)
couldn't open file "Scope.pdf"