2011-03-28 91 views
0

我只想要的是圖像顯示沒有別的請。圖像不能顯示

我一直在處理不同的腳本,但有同樣的問題。

我的圖像被刪除但不顯示。

我的代碼是:

<?php 
// directory separator 
defined("DS") 
    || define("DS", DIRECTORY_SEPARATOR); 

// root path 
defined("ROOT_PATH") 
    || define("ROOT_PATH", realpath(dirname(__FILE__))); 

// upload folder directory 
defined("UPLOAD_DIR") 
    || define("UPLOAD_DIR", "../imagefolder"); 

// path to the upload folder 
defined("UPLOAD_PATH") 
    || define("UPLOAD_PATH", ROOT_PATH.DS.UPLOAD_DIR); 


function getAllFiles($folder = null) { 
    if(!empty($folder) && is_dir($folder)) { 
     if($handle = opendir($folder)) { 
      $out = array(); 
      while($file = readdir($handle)) { 
       if(is_file($folder.DS.$file)) { 
        $out[] = $file; 
       } 
      } 
      closedir($handle); 
      return $out; 
     } 
     return false; 
    } 
    return false; 
} 

$files = getAllFiles(UPLOAD_PATH); 

if (!empty($_POST['file'])) { 
    foreach($_POST['file'] as $file) { 
     unlink(UPLOAD_PATH.DS.$file) or die("Failed to <strong class='highlight'>delete</strong> file"); 
    } 
    header("location: " . $_SERVER['REQUEST_URI']); 
} 
?> 

<?php if (!empty($files)) { ?> 

    <form name="form1" method="post"> 
     <?php foreach($files as $key => $file) { ?> 
      <label for="file_<?php echo $key; ?>"> 
       <input type="checkbox" name="file[]" id="file_<?php echo $key; ?>" value="<?php echo $file; ?>" /> 
       <?php echo UPLOAD_DIR.DS.$file; ?> 
      </label> 
     <?php } ?> 
     <input type="submit" name="delete" value="Delete" /> 
    </form> 

<?php } ?> 
+0

問題是什麼? – powtac 2011-03-28 08:09:31

+1

我期望看到 2011-03-28 08:12:40

回答

1

的問題是,我不清楚,但似乎要顯示(每個「刪除」旁邊的複選框)形式的圖像,使用戶可以看到他們是什麼刪除?

如果是的話,你可以嘗試改變

<?php echo UPLOAD_DIR.DS.$file; ?> 

<img src=<?php echo UPLOAD_DIR.DS.$file; ?> />