Can't upload file to Zoho Docs using API
Hi
I am using the free version of Zoho Docs and trying to upload a file into the root folder using PHP and the
Docs API.
My source code is as below:
- <?php
- $cipher = 'rsa_aes_128_sha';
- $AUTHTOKEN=" .... ";
- $path=" ... ";
- $filename=" ... ";
-
- $url = "https://apidocs.zoho.com/files/v1/upload?authtoken=".$AUTHTOKEN."&scope=docsapi";
-
- $fields = array(
- 'filename' => $filename,
- 'content' => file_get_contents($path."/".$filename)
- );
-
- $ch = curl_init();
-
- $query = http_build_query($fields);
-
- curl_setopt($ch, CURLOPT_POST, TRUE);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, $cipher);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
-
- $result .= curl_exec($ch);
- echo $result;
- curl_close($ch);
- ?>
The result is sometimes a properly formed response which says 'Invalid URL' and sometimes a bizarre string that just says:
The URL format appears to match that shown in the API specification. There are some other possible parameters, but these are clearly stated to be optional.
I have checked that the filename and path are correct, the file has proper permissions and the file contents are being read okay, and query string being constructed properly. The file size is well under the maximum 100M. Other Docs API functions work okay with the same AuthToken.
What might be going wrong with the file upload?
Sticky Posts
Deprecation of certain URL patterns for published Zoho Writer documents
Hi Zoho Writer users! We'd like to let you know that we have deprecated certain URL patterns for published and embedded documents in Zoho Writer due to security reasons. If the published or embedded documents are in any of these URL patterns, then their
[Announcement] Insert image from URL changes in Zoho Writer
Hi Zoho Writer users! We'd like to let you know that we've changed the behavior of the Insert image from URL option in Zoho Writer for security reasons. Earlier behavior Once you inserted an image URL in a Writer document, the image would be fetched from
Introducing plagiarism checker in Zoho Writer
Zia, Zoho Writer's AI-driven writing assistant, now highlights plagiarized and duplicated content in addition to offering contextual grammar and writing suggestions to help you write clearly and concisely in English. Zoho Writer's plagiarism reports Here
[Important announcement] Impact of Google's new email guidelines for Zoho Writer automation users
Hi users, Google has recently announced new guidelines for sending emails to Gmail and other Google-hosted domains. These guidelines will be effective starting Feb. 1, 2024, and can impact the delivery of emails sent from Zoho Writer. Your organization
Transitioning from MS Word to Writer: A complete walkthrough
Hello everyone! We understand moving to a new word processing tool can be difficult, especially if it means switching from a legacy software like MS Word. That's why we've organized an exclusive webinar where we talk you through ways to make your switch from MS Word to Writer as easy as possible. In this webinar, you'll learn: - Why Writer is a simple yet powerful alternative to MS Word. - How to locate your favorite MS Word features and functions in Writer. - How to migrate your Word documents