Reply to Re: Problem with multiple upload files

Re: Problem with multiple upload files new!
by colin, 17 years, 8 months ago
You need to instanciate the class only once into your loop.

Your code should be:
[...]
// now we can loop through $files, and feed each element to the class
foreach ($files as $file) {

    // we instanciate the class for each element of $file
    $handle = new Upload($file);

    // then we check if the file has been uploaded properly
    // in its *temporary* location in the server (often, it is /tmp)
    if ($handle->uploaded) {
        $data = $_POST["data"];
        $local = explode("-", $pasta);
        
        // configuratio para thumb
        $handle->image_resize		= true;
        $handle->image_ratio_y		= true;
        
        $handle->image_x 			= 90;
        $handle->jpeg_quality      = 100;

        $handle->file_new_name_body   = ''.$local[0].'_'.$data.'';
        $handle->file_new_name_ext = 'jpg';
        $handle->Process('../galerias/'.$local[0].'/thumbs');
        
        
        // configuratio para imagem normal
        $handle->image_resize         = true;
        $handle->image_ratio_y        = true;
        $handle->image_x              = 400;
        
        $handle->jpeg_quality         = 90;
        
        $handle->image_watermark       = "../imagens/watermark.png"; 
        $handle->image_watermark_position = 'BR'; 

        $handle->file_new_name_body   = ''.$local[0].'_'.$data.'';
        $handle->file_new_name_ext = 'jpg';
        $handle->Process('../galerias/'.$local[0].'/normal');

        // we check if everything went OK
        if ($handle->processed)  {
           [...]
        } else  {
            [...]
        }
    } else {
        [...];
    }
}
Reply

Your reply

Name *
Email 
Title *
Text *
CAPTCHA image
Enter the code displayed on the image:
Click on the image to generate another one if it is hard to read it. The case is important