Can';t从PHP400上传到谷歌文档错误!

Can';t从PHP400上传到谷歌文档错误!,php,zend-framework,error-handling,Php,Zend Framework,Error Handling,嗨,伙计们,我正试图使用以下代码在谷歌应用程序帐户上上传到谷歌文档-我正在使用zend framework: function getGoogleClient($s = '') { $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME; $user = 'aaaaa'; $pass = 'aaaaa'; $httpClient = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $

嗨,伙计们,我正试图使用以下代码在谷歌应用程序帐户上上传到谷歌文档-我正在使用zend framework:

function getGoogleClient($s = '')
{
  $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME; 

  $user = 'aaaaa';
  $pass = 'aaaaa';

  $httpClient = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);

  return $httpClient;
}

function uploadDocument($docs, $html, $originalFileName, $temporaryFileLocation) {
    $fileToUpload = $originalFileName;
    if ($temporaryFileLocation) {
        $fileToUpload = $temporaryFileLocation;
    }

    $newDocumentEntry = $docs->uploadFile($fileToUpload, $originalFileName, null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);

}



$client = getGoogleClient();
$docs = new Zend_Gdata_Docs($client);
$ls = uploadDocument($docs, true, $file->filename, $file->tmp_name);
但我一直在犯这样的错误——这里出了什么问题:(

Zend_Gdata_文档中有一个mimetype的“bug”。 如果您使用的是临时文件,并且文件名作为标题,它将不会自动神奇地为您提取mimetype。它会尝试根据临时文件中不存在的fileLocation扩展名提取mimetype

我创建了一个适合我的类,而不是更新Zend类。 之所以叫它,是因为我想

你真正需要的是这个

    // get mimetype from original file name
    $filenameParts = explode('.', $originalFileName);
    $fileExtension = end($filenameParts);
    $mimeType = Zend_Gdata_Docs::lookupMimeType($fileExtension);

并传递$mimetype而不是null。

此代码对我有效(使用
$file->tmp\u name
调用
uploadDocument()
)。您的凭据正确吗?您可以通过webinterface上传文档吗?您试图上传什么类型的文件?是否有其他程序访问此文档(尝试关闭word、excel或openoffice)?null?我正在向其传递文件->tmp_名称是指上传文件的临时位置,如$_文件[tmp_名称]
null
用于调试,如果您的代码用于将本地文件上传到google文档,则使用php脚本中的代码,而不使用Web服务器(
$文件[tmp_名称]
)所以你的问题在其他地方。或者在我上面提到的事情中,或者在你的tmp文件处理中。
    // get mimetype from original file name
    $filenameParts = explode('.', $originalFileName);
    $fileExtension = end($filenameParts);
    $mimeType = Zend_Gdata_Docs::lookupMimeType($fileExtension);