【问题标题】:removing the trailing (space) %20 after images删除图像后的尾随(空格)%20
【发布时间】:2013-02-15 19:21:06
【问题描述】:

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

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

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

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

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

【问题讨论】:

  • 哪个代码调用了这个 URL?你生成它?

标签: codeigniter space codeigniter-url trailing


【解决方案1】:

先尝试修剪和解码

$image = trim(urldecode($image));

【讨论】:

    【解决方案2】:

    您需要使用 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
    

    【讨论】:

      猜你喜欢
      • 2015-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-05
      • 2020-06-04
      相关资源
      最近更新 更多