PHP Google Drive API - File Upload Only As “Untitl

2019-05-11 13:52发布

问题:

I am searching for a solution to upload files from my root server directly to my Google Drive-account via PHP.

Authorisation is working fine, but when I try to transfer a file (for example "test.jpg"), it just creates a file named "Untitled" in Google Drive. It also ignores the folder where to save it in and creates it in the main-folder.

If I use the same save-function, with the same parameters, but just leave the file-content empty everything works fine. The file gets created with the correct filename in the correct subfolder - everything I want - but without the filedata.

Is it perhaps a configuration-problem?

I am using the following code (see the php-example at the bottom) for transfering the files: https://developers.google.com/drive/v2/reference/files/update

Many thanks for your answers!!

回答1:

Just got an answer on my own related question, just make a copy of the files here http://code.google.com/p/google-api-php-client/source/browse/trunk/src/#src%253Fstate%253Dclosed - it should work.



回答2:

It's rather: https://developers.google.com/drive/v2/reference/files/insert ... for creating new files.

Method "update" provides functionality for creating new revisions or overwriting existing files.