0

我从丢失图像的错误日志中收到错误消息。出现丢失的原因是因为在图像文件扩展名之后有一个这样的空格

上传/图片/thumbs/natasha.jpg%20

这个 404 错误并不总是发生,它有时会发生。

我已经在 Codeigniter php 框架上构建了该项目。

我应该怎么做才能删除尾随空格?

4

2 回答 2

2

尝试先修剪和解码

$image = trim(urldecode($image));
于 2013-03-06T06:09:21.043 回答
0

您需要使用 trim() 函数。( http://au1.php.net/manual/en/function.trim.php )

例如

$image = " this/is/the/path/to/myimage.jpg ";
// Note the spaces around the string

$image = trim($image);
// $image now equals "thisis/the/path/to/myimage.jpg"
// Note: no spaces
于 2013-03-06T06:05:12.527 回答