href语法:可以在文件名中使用空格 [英] href syntax : is it okay to have space in file name
问题描述
一直以来我的做法是,当我使用图像时,我将它们命名为
walls_ico
, bu_hover $ c $所以当我给他们的路径,他们就像
< / p> ; img src =images / walls_ico.ico/>
< img src =buttons / bu_hover.png/>
直到现在,当我在用户上传文件的项目时...
我想知道是否可以在文件和文件夹名称之间存在空格,如
< img src =按钮/ bu hover.png/>
src
属性应该包含有效的网址。由于网址中空格字符不允许,因此您必须编码。
你可以写:
< img src =buttons / bu%20hover.png/>
但是不是:
< img src =buttons / bu + hover.png/>
由于DavidRR在他的评论中正确地指出,编码空间字符为 +
仅在URL的查询字符串部分有效,而不在路径本身中。
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" />
The src
attribute should contain a valid URL. Since space characters are not allowed in URLs, you have to encode them.
You can write:
<img src="buttons/bu%20hover.png" />
But not:
<img src="buttons/bu+hover.png" />
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屋!