PHP复制命令失败时空格? [英] PHP Copy command failing when spaces?
本文介绍了PHP复制命令失败时空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在执行以下命令:
<?php
copy ("http://localhost/.../DSCF8253.JPG" , "sites/default/files/DSCF8253.JPG"); // Success!
copy ("http://localhost/.../DSCF8260.JPG" , "sites/default/files/DSCF8260.JPG"); // Success!
copy ("http://localhost/.../HERMAN 085.jpg" , "sites/default/files/HERMAN 085.jpg" ); // Fail!
?>
前两个副本很好,但不是最后一个。为什么?
The first two copy fine, but not the last one. Why?
它必须与文件名有关(最后一个在085之前有一个SPACE)。
It must have something to do with the filenames (the last one has a SPACE before the 085).
任何帮助将非常感谢。
推荐答案
http://localhost/.../HERMAN 085.jpg
应为
http://localhost/.../HERMAN%20085.jpg
复制&当涉及到无效的URL时,http包装器不那么宽容,然后浏览器/用户代理。网址中的空格无效,因此应为 urlencode
'd 。
Copy & the http wrappers are less forgiving then browsers / user-agents when it comes to invalid urls. A space in an url is invalid, so it should be urlencode
'd.
这篇关于PHP复制命令失败时空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文