2013-12-17 50 views
1

一旦我編寫了一個PHP腳本,它應該已經將一些圖像下載到普通的網絡服務器。 出了毛病,這個劇本,現在我有很多的文件與文件大小爲0。一個目錄當我嘗試刪除一個與FileZilla的服務器只回應:無法用Filezilla刪除文件

550 nameOfTheFile.jpg: No file or directory

我該怎麼做擺脫所有這些datatrash?

好像有隻保存在服務器上的文件名,而不是文件

+0

你有shell訪問服務器嗎? – Nick

+0

不,我沒有shell訪問 – frieder

+0

嗯,奇怪的消息。你有沒有嘗試點擊右鍵 - >重新加載(刷新)檢查,如果文件仍然存在? –

回答

1

這裏有一段代碼,我發現here

As per original comment

<?php 

$dir_stack = array('test/'); // put the directory to delete here **NOTE** everything in this will be deleted. 
$i = 0; 
while ($i <= count($dir_stack)-1) 
{ 
    echo $dir_stack[$i].'<br>'; 
    if ($dir = opendir($dir_stack[$i])) 
    { 
     while (false !== ($file = readdir($dir))) 
     { 
      if ($file != "." && $file != ".." && false == is_dir($dir_stack[$i].$file)) 
      { 
       unlink($dir_stack[$i].$file); 
      } 
      elseif ($file != "." && $file != "..") 
      { 
       array_push($dir_stack,$dir_stack[$i].$file.'/'); 
      } 
     } 
     closedir($dir); 
    } 
    $i++; 
} 
$i = count($dir_stack)-1; 
while ($i >= 0) 
{ 
    rmdir($dir_stack[$i]); 
    $i--; 
} 
?> 
1

這是代碼,我發現,令人驚訝它的工作

<?php 

$dir_stack = array('filedirectory'); // put the directory to delete here **NOTE** everything in this will be deleted. 
$i = 0; 
while ($i <= count($dir_stack)-1) 
{ 
    echo $dir_stack[$i].'<br>'; 
    if ($dir = opendir($dir_stack[$i])) 
    { 
     while (false !== ($file = readdir($dir))) 
     { 
      if ($file != "." && $file != ".." && false == is_dir($dir_stack[$i].$file)) 
      { 
       unlink($dir_stack[$i].$file); 
      } 
      elseif ($file != "." && $file != "..") 
      { 
       array_push($dir_stack,$dir_stack[$i].$file.'/'); 
      } 
     } 
     closedir($dir); 
    } 
    $i++; 
} 
$i = count($dir_stack)-1; 
while ($i >= 0) 
{ 
    rmdir($dir_stack[$i]); 
    $i--; 
} 

?> 
+0

太棒了!看起來像我找到的代碼和我放入的評論。畢竟是一個美滿的結局。 –

+0

是的,它是:) 你想要的信貸? – frieder

+0

如果您願意,我可以提供答案。 –