href 语法:文件名中是否可以有空格 [英] href syntax : is it okay to have space in file name
本文介绍了href 语法:文件名中是否可以有空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直以来的习惯是,每当我使用图像时,我都会将它们命名为walls_ico
, bu_hover
it has always been my practice that when ever i use images i name them like
walls_ico
, bu_hover
所以当我给出路径时,它们会像
so when i give paths they go like
<img src="images/walls_ico.ico" />
<img src="buttons/bu_hover.png" />
直到现在当我在一个用户上传文件的项目中......
UNTIL now when i am on a project where users upload files...
我想知道文件名和文件夹名之间是否可以有空格
i was wondering is it okay to have spaces between file and folders name like
<img src="buttons/bu hover.png" />
推荐答案
src
属性应包含有效网址.由于 不允许在 URL 中使用空格字符,您必须编码.
你可以写:
<img src="buttons/bu%20hover.png" />
但不是:
<img src="buttons/bu+hover.png" />
因为,正如 DavidRR 在他的评论中正确指出的那样,将空格字符编码为 +
仅在 URL 的查询字符串部分有效,在路径本身中无效.
Because, as DavidRR rightfully points out in his comment, encoding space characters as +
is only valid in the query string portion of an URL, not in the path itself.
这篇关于href 语法:文件名中是否可以有空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文