2014-01-28 226 views
0

我有問題,這樣的代碼:未能打開流:權限被拒絕

form.php的

$dir = date("d-m-y(H-i-s)"); 
    mkdir('../files/'.$dir, 0755, true); 
    mkdir('../files/'.$dir.'/files', 0755, true); 
    mkdir('../files/'.$dir.'/imgs', 0755, true); 
    mkdir('../files/'.$dir.'/thumb', 0755, true); 

    //<input type="hidden" name="folder" value="<?php echo $dir ?>"/> 

upload.php的

$count = 0; 
$DIR = $_POST['folder']; 
$imgsDIR = '../files/'.$DIR.'/imgs/'; 
$thumbDIR = '../files/'.$DIR.'/thumb'; 

    foreach ($_FILES['img']['name'] as $filename) 
     { 
      $tmp = $_FILES['img']['tmp_name'][$count]; 
      $temp = $imgsDIR.$filename; 
      move_uploaded_file($tmp,$temp); 
      make_thumb($temp ,$thumbDIR ,150); 
      $temp=''; 
      $tmp=''; 
      $count++; 
     } 

function make_thumb($src, $dest, $desired_width) { 

$source_image = imagecreatefromjpeg($src);//ok 
//some cods 
imagejpeg($virtual_image, $dest);//error Permission denied 
} 

我也tryed 06440777但不起作用 和我使用(完全控制)這個褶皺呃

+0

是應該的根製成的文件網站的目錄? 您是否嘗試/文件? /files是站點根的子文件,./files是當前目錄的子文件。 – Lexib0y

+2

調用'make_thumb'時不應該在''thumbDir'附加一個文件名? 'make_thumb($ temp,$ thumbDir。'/'。$ filename,150);' – Cyclonecode

+0

是的,我嘗試了網站的任何目錄 – talkhabi

回答

2

調用make_thumb()否則你會嘗試將生成的縮略圖存儲與同名的縮略圖目錄時,您需要將文件名追加到$thumbDir

foreach ($_FILES['img']['name'] as $filename) { 
    $tmp = $_FILES['img']['tmp_name'][$count]; 
    $temp = $imgsDIR.$filename; 
    move_uploaded_file($tmp, $temp); 
    // make sure you have a filename and not only an directory path 
    make_thumb($temp, $thumbDIR.'/'.$filename, 150); 
    $temp=''; 
    $tmp=''; 
    $count++; 
} 
+0

謝謝你這個工作 – talkhabi

相關問題