删除文件名中带有特殊字符的文件 [英] Delete files with special characters in filenames

查看:433
本文介绍了删除文件名中带有特殊字符的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要删除文件名中包含空格,等。经典 unlink($ filename)不适用于这些文件。如何将文件名转换为接受unlink函数和文件系统的文件名?它在Solaris机器上运行,我没有其他访问权限。

解决方案

$ c> $ filename ? unlink应该工作在任何文件名有特殊字符,如果你做正常的转义它。例如

这个名称为的文件,其中有各种/ wonky!字符 p>

  $ filename ='this has\,various \ / wonky \!characters in it'; 
unlink($ filename);

应该可以正常工作。


I need to delete old files with special characters in filenames like space,,,(,),! and so on via PHP. Classic unlink($filename) does not work for these files. How can I transform filenames to filenames which accepts unlink function and filesystem? It's running on a Solaris machine and I don't have another access to it.

解决方案

How are you constructing the $filename? unlink should work on any filename with special characters if you do the normal escaping on it. e.g.

for a file with a name of this has, various/wonky !characters in it, then

 $filename = 'this has\, various\/wonky \!characters in it';
 unlink($filename);

should work.

这篇关于删除文件名中带有特殊字符的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆