嗨,我使用下面的脚本将图像从另一个域保存到我自己的域。试图保存图像的名称完好无损php
//get image name and extension
$img = 'http://otherdomain.com/image/123.jpg';
$getname = explode('/', $img);
$thumbname = $getname[count($getname) - 1];
//save the image file
$file = file_get_contents($img);
$path = 'thumbs/'+ $thumbname;
file_put_contents($path, $file);
,但我不能得到这个工作。 $路径导致123
但不是123.jpg
(我需要)。 和我在做文件获取内容和文件把内容正确吗?
也许您使用带有“隐藏已知文件扩展名”选项的窗口。你的脚本对我完全没问题。 – 2012-04-14 08:36:55