处理带有空格的文件名 [英] Dealing with filenames which have white spaces

查看:74
本文介绍了处理带有空格的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的脚本在这里工作正常:

My script here works fine:

codeigniter中的图像保护

但是,如果我的文件名带有空格,它将显示损坏的图像,所以说它是"obama 1.jpg".

However it displays a broken image if my filename has a space, so say it is "obama 1.jpg".

要尝试解决此问题,我使用了 http://php.net/manual/zh-CN/function.escapeshellarg.php

To try and resolve this problem, I have used http://php.net/manual/en/function.escapeshellarg.php

并将img_id中的所有空白替换为%".

And replaced all the white spaces in the img_id with "%"s.

但是我没有运气.我无法去除空格,因此必须根据字符串的结构来确定.

But I have had no luck. I cannot strip the white spaces out, so will have to make due with the structure of the string.

感谢您的帮助.

推荐答案

调用图像时,只需使用

echo urlencode($image_name);

那应该解决它!

这篇关于处理带有空格的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆