imagecreatefromjpeg() 的奇怪问题

发布于 2024-11-11 18:44:13 字数 1148 浏览 2 评论 0原文

我有一个非常奇怪的问题,我正在将 csv 中的产品列表导入到新网站中。 一部分是复制图像并调整其大小,但我遇到了一个非常奇怪的问题。

$path = $_SERVER['DOCUMENT_ROOT']."/production/public/storage/Productimages/".$product['largepic'];
echo $path;
imagecreatefromjpeg($path);

如果我执行这部分,我会收到此错误:

/home/xxxx/domains/xxxx/public_html/production/public/storage/Productimages/1A(19).jpg
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /home/xxxx/domains/xxxx/public_html/production/public/import.php on line 27
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '/home/xxxx/domains/xxxx/public_html/production/public/storage/Productimages/' is not a valid JPEG file in /home/xxxx/domains/xxxx/public_html/production/public/import.php on line 27

但是当我复制我正在回显的完整路径时:

/home/xxxx/domains/xxxx/public_html/production/public/storage/Productimages/1A(19).jpg

并像这样使用它:

imagecreatefromjpeg("/home/xxxx/domains/xxxx/public_html/production/public/storage/Productimages/1A(19).jpg");

然后它可以工作!?

我希望有人能帮忙:(

I have a very weird problem, i am importing a product list into a new website from csv.
One part is to copy the image and resize it, but i am having a very weird problem with it.

$path = $_SERVER['DOCUMENT_ROOT']."/production/public/storage/Productimages/".$product['largepic'];
echo $path;
imagecreatefromjpeg($path);

If i execute this part I am getting this error:

/home/xxxx/domains/xxxx/public_html/production/public/storage/Productimages/1A(19).jpg
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: gd-jpeg: JPEG library reports unrecoverable error: in /home/xxxx/domains/xxxx/public_html/production/public/import.php on line 27
Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: '/home/xxxx/domains/xxxx/public_html/production/public/storage/Productimages/' is not a valid JPEG file in /home/xxxx/domains/xxxx/public_html/production/public/import.php on line 27

But when i copy the full path that i am echoing:

/home/xxxx/domains/xxxx/public_html/production/public/storage/Productimages/1A(19).jpg

And use that like this:

imagecreatefromjpeg("/home/xxxx/domains/xxxx/public_html/production/public/storage/Productimages/1A(19).jpg");

Then it works!?

I hope someone can help :(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

秋凉 2024-11-18 18:44:13

尝试以下代码片段,看看它是否有效。

$path = (string) $_SERVER['DOCUMENT_ROOT']."/production/public/storage/Productimages/".$product['largepic'];
echo $path;
imagecreatefromjpeg($path);

可能是字符集问题。

Try the following snippet and see if it works.

$path = (string) $_SERVER['DOCUMENT_ROOT']."/production/public/storage/Productimages/".$product['largepic'];
echo $path;
imagecreatefromjpeg($path);

It could be problem with charset.

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