[Developers] Problems uploading images
Coral Link
corallink at gmail.com
Mon Dec 31 00:58:10 UTC 2007
Hi; I'm using PHP/LibCURL to upload images relevant to my topics. I'm
guessing its more of a PHP issue than Freebase, but hopefully someone will
indulge a helping hand.
I'm running into this problem when uploading an image:
{ "status": "400 Application Error", "code": "/api/status/error",
"messages": [ { "info": { "exception": "cannot identify image file" },
"message": "Invalid image file.", "code":
"/api/status/error/upload/invalid_image_data" } ] }
When I run the following:
$content="@/hole/www/corallink.com/freebase/files/uwlImage/9202a8c04000641f80000000060b61a7/CORAL.gif";
$type="image/gif";
$request = curl_init($url);
curl_setopt($request, CURLOPT_COOKIEFILE, $cookiejarfile); //get some
cookies
curl_setopt($request, CURLOPT_POST, 1);
curl_setopt($request, CURLOPT_HTTPHEADER, array("X-Metaweb-Request: TRUE",
"Content-Type: ".$type));
curl_setopt($request, CURLOPT_POSTFIELDS,$content);
// Return the result instead of printing it out.
curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($request, CURLOPT_COOKIE, $credentials);
// Now fetch the URL
$responsetext = curl_exec($request);
curl_close($request);
This same code works great for uploading documents for the description in
/common/topic. I've tried variations where I've made
$content=array("file"=>"@ filename.gif"), which uploaded data, but Freebase
tagged it as media_type 'octet/stream'. Any suggestions will be
appreciated.
Thank you and kind regards,
Indy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freebase.com/pipermail/developers/attachments/20071230/2b0aae4e/attachment-0001.htm
More information about the Developers
mailing list