How to access a file name containing URL encoding through the browser?

被刻印的时光 ゝ 提交于 2019-12-24 16:46:03

问题


I created a file name called "%20%20.txt" and uploaded in my webs space.

When I am trying to access above file through URL by typing "http://mysite/%20%20.txt", it is showing an error that the file is not found. I know that "%20" will be decoded as a blank space.

How is it possible to access the file through URL?


回答1:


The %20 that you use in the URL will be decoded, so you are looking for the file " .txt", but the %20 that you used to create the file is not decoded, so the actual name of the file is "%20%20.txt".

You need to use the URL http://mysite/%2520%2520.txt to access the file "%20%20.txt". The %25 is the encoded form of %.




回答2:


Use %2520%2520.txt, %25 decodes as the percent-sign %. You can use the table on http://www.asciitable.com/. The number after the percent-sign is a hexadecimal representation of the ASCII value.

If you have a long string, you could also use Javascript's encodeURIComponent function:

prompt("Encoded:", encodeURIComponent("%20%20.txt"))

This could be executed in the Javascript console (Ctrl + Shift + J in Firefox) and displays a dialog containing the escape value.




回答3:


If your file name really is %20%20.txt, try http://yoursite.com/%2520%2520.txt.

%25 is the percentage encoded.




回答4:


You need to escape those percent signs:

http://mysite/%2520%2520.txt


来源:https://stackoverflow.com/questions/11070499/how-to-access-a-file-name-containing-url-encoding-through-the-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!