Php 获取图像的url名称时出错?

Php 获取图像的url名称时出错?,php,Php,我有一个代码下载图片从链接 当开始是链接格式时: 但当下载此链接时,链接将变成 如何修复它 代码在这里 <?php include_once 'class.get.image.php'; // initialize the class $image = new GetImage; $image->source = 'http://test.com/test[1].jpg'; $image->save_to = 'images/'; // with trailing slash

我有一个代码下载图片从链接 当开始是链接格式时:
但当下载此链接时,链接将变成
如何修复它

代码在这里

<?php
include_once 'class.get.image.php';

// initialize the class
$image = new GetImage;
$image->source = 'http://test.com/test[1].jpg';
$image->save_to = 'images/'; // with trailing slash at the end

$get = $image->download('gd'); // using GD

if($get)
{
echo 'The image has been saved.';
}
?>

在php中查找urldecode,将编码值更改回括号中。 在这条线上

$image->source = 'http://test.com/test[1].jpg';
改为

$image->source = htmlspecialchars_decode('http://test.com/test[1].jpg');

如果“test3%5B1%5D.jpg”是urlencoded值,则代码有问题,因为“3”不应该存在。或者您的变量名是“test3”?可能会粘贴您尝试过的部分代码。您确定这是正确的吗<代码>测试[1]。jpg(不是
$test[1]。jpg
)?只需对结果运行urldecode(),保持原样即可。这是有效的编码。还有,那个笨重的类是干什么用的?为什么不直接复制http://test.com/test[1] .jpg','images/test[1].jpg')?