准备上传GD动态图

发布于 2024-10-05 16:16:45 字数 648 浏览 0 评论 0原文

如何准备 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝礼 2024-10-12 16:16:45

看起来该脚本尝试直接从文件系统读取文件,而不是运行图像生成脚本。如果 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文