简体   繁体   English

使用PHP删除文件夹的空间

[英]Remove space of folder using php

I am uploading zip file using php, when i extract the folder using, 我使用php上传zip文件,当我使用提取文件夹时,

$zip = new ZipArchive;
if ($zip->open("test.zip") === TRUE) {
$zip->extractTo($pat."/");
$zip->close();
} 

all are working fine. 一切都很好。 But if suppose, the uploaded zip format file name is for ex(new folder) that is space between name means. 但是,如果假设的话,上载的zip格式文件名是用于ex(新文件夹)的,则文件名之间是空格。 It not possible for me to get the name of folder. 我无法获取文件夹的名称。

If it's not necessary that the spaces are kept you can use the "ereg_replace" function: 如果没有必要保留空格,则可以使用“ ereg_replace”函数:

$var =$_FILES['Filedata']['name'];
$name= ereg_replace(" ","_",$var); 

So "new folder" will become "new_folder". 因此,“新文件夹”将变为“ new_folder”。

i found the answer, 我找到了答案,

$var =$_FILES['Filedata']['name'];
$name= str_replace(" ","\ ",$var);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM