Pregunta

i have problem with this code :

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  
}

i also tryed 0644 , 0777 but does not work and i used (full control) for this folder

¿Fue útil?

Solución

You need to append a filename to $thumbDir when calling make_thumb() or else you will try to store the created thumbnail with the same name as the thumbnail directory:

 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++;
 }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top