Php Google Drive API:插入文件时出错";内部错误(代码:4200)“;

Php Google Drive API:插入文件时出错";内部错误(代码:4200)“;,php,excel,google-drive-api,Php,Excel,Google Drive Api,我使用驱动器API已经一年多了。 但有时,我在上传时会出现以下错误: 我升级到了1.0.x版本,但仍然出现了这个错误,只是在xls文件上 “调用POST时出错:(500)内部错误(代码:4200)” 这是插入的代码,它适用于除xls以外的所有其他文件 $createdFile = $this->service->files->insert($gdfile, array( 'data' => $data, 'mimeType'

我使用驱动器API已经一年多了。 但有时,我在上传时会出现以下错误:

我升级到了1.0.x版本,但仍然出现了这个错误,只是在xls文件上

“调用POST时出错:(500)内部错误(代码:4200)”

这是插入的代码,它适用于除xls以外的所有其他文件

    $createdFile = $this->service->files->insert($gdfile, array(
          'data' => $data,
          'mimeType' => $this->filemimetype,              
                'uploadType' => 'multipart',
          'convert' => true,
        ));
我在通过Chrome将其上传到硬盘时也出现了一个错误

“无法粘贴ce文档倒l'instant”->“尚无法显示此文档”


Excel文件在Excel中可以很好地打开。

确保您的
$this->filemimetype
具有不带字符集部分的mimetype

我遇到了完全相同的问题。
原来是因为传递给insert方法的mimetype不正确。
当我尝试上载excel文件时,
finfo\u open(FILEINFO\u MIME)
函数返回了mimetype,其中包含以下附加字符集信息:
“application/vnd.ms-excel;charset=binary”

在将其传递给Google_DriveFile对象之前,我必须用字符集去掉该部分

$finfo = finfo_open(FILEINFO_MIME); 
$mimetype = finfo_file($finfo, $filename);
$mimetype = preg_replace('/;.*/','',$mimetype);