Home  >  Article  >  Backend Development  >  thinkphp删除文件怎么获取不到文件的后缀?

thinkphp删除文件怎么获取不到文件的后缀?

WBOY
WBOYOriginal
2016-06-23 13:16:02844browse

删除文件,提示删除失败,最后var_bump一看,文件没带后缀。地址:http://localhost/2015/thinkphp/blog/User/Database/index/Action/del/file/D20160105T144608-1.sql是这个,我用var_dump($_GET)打印出来的是:

array(2) {  ["Action"]=>  string(3) "del"  ["file"]=>  string(18) "D20160105T144608-1"}{"success":0}

要获取的是file的值,百度好多没有找到答案,真够郁闷的了。


回复讨论(解决方案)

这就是 TP 的事情了,他把后缀另行解释了
你可以从 $_SERVER['PATH_INFO'] 或 $_SERVER['REQUEST_URI'] 中自行获取

这就是 TP 的事情了,他把后缀另行解释了
你可以从 $_SERVER['PATH_INFO'] 或 $_SERVER['REQUEST_URI'] 中自行获取


前一个path_info可以获取整个路径,而后一个request_url获取不到后缀,我在文件后面随意自定义了个参数就自动解析了,真搞不懂。
U('Database/Index',array('Action'=>'del','file'=>$row,'tm'=>1))解析后的路径就是:
http://localhost/2015/thinkphp/blog/User/Database/index/Action/del/file/D20160105T144608-1.sql/tm/1在这种情况下就可以获取到file的正确值。

再加个参数,.sql 就不是 url 的后缀了
自然也就摆脱了 TP 的误解

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn