开发者

Can't upload from my php form to google docs - getting error

Hi guys I'm building a form that uploads documents to my google docs account however its not working I keep getting an error - the following is my code;

$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($username, $pww, $service);
$docs = new Zend_Gdat开发者_开发技巧a_Docs($client);

$newDocumentEntry = $docs->uploadFile($_FILES['file']['tmp_name'], $_FILES['file']['name'], null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);

I get the following error:

PHP Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Expected response code 200, got 400 Inconsistent repeating query parameter ' in C:...\Zend\Gdata\App.php:700

I'm using php and the Zend gdata code.


There is a "bug" in Zend_Gdata_Docs with the mimetype. If you are using a temporary file and the filename as the title it will not auto-magically pull the mimetype for you. It tries to pull the mimetype based on the fileLocation extension which does not exist on a temporary file.

I made a class that works for me, rather than updating the Zend class. It is called ConvertDoc because I wanted to be able to upload a spreadsheet and download as csv.

What you really need is this...

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

And pass the $mimetype instead of null.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜