Ciao, io uso QUESTA classe per l'upload e resize multiplo di immagini. Funziona molto bene e ci puoi fare molte cose. Il problema è che l'upload lo fa ma il salvataggio su Mysql del nome delle immagini no, per fare questo ho un array, che però non mi restituisce nulla.. mi viene il dubbio che l'errore sia dovuto all'array che forse è vuoto a questo punto. L'errore è:

Notice: Undefined variable: id in C:\AppServ\www\uploadresize\class.upload.php\class .upload_0.25\upload.php on line 150

Notice: Undefined offset: 3 in C:\AppServ\www\uploadresize\class.upload.php\class .upload_0.25\upload.php on line 150

Notice: Undefined offset: 3 in C:\AppServ\www\uploadresize\class.upload.php\class .upload_0.25\upload.php on line 150

che corrisponde alla linea:

$sql .= "VALUES ('$id', '".$uploaded[1]['large']."', '".$uploaded[1]['small']."', '".$uploaded[2]['large']."', '".$uploaded[2]['small']."', '".$uploaded[3]['large']."', '".$uploaded[3]['small']."')";

l'intero file upload.php:

<?php

error_reporting(E_ALL);

// we first include the upload class, as we will need it here to deal with the uploaded file
include('class.upload.php');

// ---------- IMAGE UPLOAD ----------

// we create an instance of the class, giving as argument the PHP object
// corresponding to the file field from the form
// All the uploads are accessible from the PHP object $_FILES
//$handle = new Upload($_FILES['my_field']);
// as it is multiple uploads, we will parse the $_FILES array to reorganize it into $files
$files = array();
foreach ($_FILES['my_field'] as $k => $l) {
foreach ($l as $i => $v) {
if (!array_key_exists($i, $files))
$files[$i] = array();
$files[$i][$k] = $v;
}
}

// create an array here to hold file names
$uploaded = array();

// 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);
if ($handle->uploaded) {

// create a little array for this set of pictures
$this_upload = array();

// yes, the file is on the server
// below are some example settings which can be used if the uploaded file is an image.
$handle->file_name_body_add = '_peque';
$handle->file_auto_rename = true;
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_x = 500;

// now, we start the upload 'process'. That is, to copy the uploaded file
// from its temporary location to the wanted location
// It could be something like $handle->Process('/home/www/my_uploads/');
$handle->Process('./test/');

// we check if everything went OK
if ($handle->processed) {
// everything was fine !
echo ' file uploaded with success';
echo ' [img]test/' . $handle->file_dst_name . '[/img]';
$info = getimagesize($handle->file_dst_pathname);
echo '

' . $info['mime'] . ' - ' . $info[0] . ' x ' . $info[1] .' - ' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB</p>';
echo ' link to the file just uploaded: ' . $handle->file_dst_name . '
';
// store the large image filename
$this_upload['large'] = $handle->file_dst_name;
} else {
// one error occured
echo ' <legend>file not uploaded to the wanted location</legend>';
echo ' Error: ' . $handle->error . '';
}

$handle->file_auto_rename = true;
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_x = 200;

// now, we start the upload 'process'. That is, to copy the uploaded file
// from its temporary location to the wanted location
// It could be something like $handle->Process('/home/www/my_uploads/');
$handle->Process('./test/');

// we check if everything went OK
if ($handle->processed) {
// everything was fine !
echo ' file uploaded with success';
echo ' [img]test/' . $handle->file_dst_name . '[/img]';
$info = getimagesize($handle->file_dst_pathname);
echo '

' . $info['mime'] . ' - ' . $info[0] . ' x ' . $info[1] .' - ' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB</p>';
echo ' link to the file just uploaded: ' . $handle->file_dst_name . '
';
// store the small image filename
$this_upload['small'] = $handle->file_dst_name;
} else {
// one error occured
echo ' file not uploaded to the wanted location';
echo ' Error: ' . $handle->error . '';
}

// we delete the temporary files
$handle-> Clean();

// add this set of pictures to the main array
$uploaded[] = $this_upload;

} else {
// if we're here, the upload file failed for some reasons
// i.e. the server didn't receive the file
echo ' file not uploaded on the server';
echo ' Error: ' . $handle->error . '';
}
}

$conn = mysql_connect("localhost","root","password") or die(mysql_error());
mysql_select_db("database",$conn) or die(mysql_error());

echo '<pre>';
print_r($uploaded, 1);
echo '</pre>';

$sql = "INSERT INTO immobili (id, pic1, pic1_small, pic2, pic2_small, pic3, pic3_small) ";
$sql .= "VALUES ('$id', '".$uploaded[1]['large']."', '".$uploaded[1]['small']."', '".$uploaded[2]['large']."', '".$uploaded[2]['small']."', '".$uploaded[3]['large']."', '".$uploaded[3]['small']."')";
$x = mysql_query($sql);

?>