URL解码无法正常工作

URL解码无法正常工作

本文介绍了URL解码无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的浏览器将URL的文件名显示为

My Browser shows URL with file name as


http://www.example.com/pdf/204177_20090604_Chloorhexidine_DCB_oogdruppels_0%2C1%25.pdf

实际文件名为204160_20090604_Atropine_DCB_oogdruppels_0,5%.pdf

在urldecode之后,它给出了错误的文件名http://www.example.com/pdf/204177_20090604_Chloorhexidine_DCB_oogdruppels_0,1%.pdf

After urldecode, it gives wrong file name ashttp://www.example.com/pdf/204177_20090604_Chloorhexidine_DCB_oogdruppels_0,1%.pdf

更新:

最初,我认为这是URL解码的问题,但是在浏览器中渲染时,名称为204153_20090605_Aluminiumacetotartraat_DCB_oordruppels_1,2%.pdf的文件会引发Bad Request.我正在使用Kohana 3框架.与服务器有关吗?

Initially I thought that its problem of URL Decode, but files like name 204153_20090605_Aluminiumacetotartraat_DCB_oordruppels_1,2%.pdf while rendering in browser throws Bad request. I am using Kohana 3 framwork. Is it related with server?

推荐答案

$url = 'http://204160_20090604_Atropine_DCB_oogdruppels_0,5%.pdf';
$encode = urlencode($url);
$decode = urldecode($encode);

echo $url."<br />";
echo $encode."<br />";
echo $decode."<br />";

// outputs
http://204160_20090604_Atropine_DCB_oogdruppels_0,5%.pdf
http%3A%2F%2F204160_20090604_Atropine_DCB_oogdruppels_0%2C5%25.pdf
http://204160_20090604_Atropine_DCB_oogdruppels_0,5%.pdf

好的.您在其他地方出错了.

All ok. You're error is somewhere else.

这篇关于URL解码无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 17:58