class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
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 {
[...];
}
}
Your code should be: