准备上传GD动态图
如何准备 GD 创建的动态图像以供上传?
我创建了一个 php 脚本来根据用户 ID 创建动态图像(例如:www.mywebsite.com/image/124.png <== 应该显示用户 124 信息)
现在我需要使用此脚本将其上传到 Facebook :
$photo_details = array(
'message'=> $message
);
$file = "$_GET[id].png";
$photo_details['image'] = '@/home/username/public_html/image/' . $file;
$upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', $photo_details);
当我以这种方式使用上传脚本时,出现此错误:
致命错误:未捕获的 CurlException:26:创建 formpost 数据失败
但是如果我将 124.png 上传到 /image/ 目录并尝试相同的操作使用 ID 124 再次编码,效果很好。经过长时间的研究,我得出的结论是动态部分的问题中继,因为它对于静态图像效果很好。我该如何解决这个问题?
非常感谢您的所有帮助。
How can I prepare a dynamic image created by GD for upload?
I created a php script to create dynamic images based on the userid (EX: www.mywebsite.com/image/124.png <== that should show the user 124 info)
Now I need to upload it to Facebook with this script :
$photo_details = array(
'message'=> $message
);
$file = "$_GET[id].png";
$photo_details['image'] = '@/home/username/public_html/image/' . $file;
$upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', $photo_details);
When I use the upload script that way I get this error:
Fatal error: Uncaught CurlException: 26: failed creating formpost data
But If I uploaded 124.png to /image/ directory and and tried the same code again with using the ID 124 it works just fine. After a long research I came to conclusion the problem relay in the dynamic part since it works just fine with static images. How can I solve this problem?
Thank you so much for all the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来该脚本尝试直接从文件系统读取文件,而不是运行图像生成脚本。如果 Facebook 类允许打开此类文件,您可以通过设置
$photo_details['image'] = 'http://www.mywebsite.com/image/'.$file;
来解决此问题。Looks like the script tries to read the file directly from the filesystem instead of running the image generating script. You can solve this by setting
$photo_details['image'] = 'http://www.mywebsite.com/image/'.$file;
if Facebook class allows this kind of file opening.