PHP上传-文件名中的空格 [英] PHP Upload - Spaces in File Name
本文介绍了PHP上传-文件名中的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用上传脚本上传PHP文件时,无法上传其中带有空格的文件(出现500错误).有没有办法让我的代码自动在文件名中加下划线而不是空格?非常感谢所有帮助.:)
When I use my upload script to upload a PHP file, I can't upload a file with spaces in it (I get a 500 error). Is there a way so my code automatically puts an underscore in the file name instead of the space? All help is greatly appreciated. :)
推荐答案
只需使用 str_replace 用另一个字符串替换所有空格:
Simply use str_replace to replace all white spaces with another string:
$fileName = str_replace(" ", "_", $fileName);
- 文档: php.net
这篇关于PHP上传-文件名中的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文