Salve a tutti, dopo l'aiuto di Telegio, che ringrazio ancora per avermi dato una mano ad unire le due pagine, volevo includere in questo stesso script la possibilità di fare un upload doppio, ho creato oltre alla tabella 'foto' una seconda 'varianti'. Ho provato a fare in questo modo, però mi restituisce l'errore che è contenuto nella pagina (ERRORE puoi inserire solo file che hanno questa estensione (.jpg or .jpeg. la tua è '...


Codice PHP:

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO prodotti (id, id_menu, id_sottomenu, titolo,lin, codice, foto, varianti) VALUES (%s,%s,%s,%s,%s,%s, %s, %s)",
                       
GetSQLValueString($_POST['id'], "int"),
                       
GetSQLValueString($_POST['id_menu'], "text"),
                       
GetSQLValueString($_POST['id_sottomenu'], "text"),
                       
GetSQLValueString($_POST['titolo'], "text"),
                       
GetSQLValueString($_POST['lin'], "text"),
                       
GetSQLValueString($_POST['codice'], "text"),
                       
GetSQLValueString($_FILES['foto']['name'], "text"),
                       
GetSQLValueString($_FILES['varianti']['name'], "text"));

  
mysql_select_db($database_conn$conn);
  
$Result1 mysql_query($insertSQL$conn) or die(mysql_error());


// UPLOAD DEL FILE

$idir "image_files/"// Path To Images Directory 
$tdir "image_files/thumbs/"// Path To Thumbnails Directory 
$twidth "120"// Maximum Width For Thumbnail Images 
$theight "125"// Maximum Height For Thumbnail Images 



$url $_FILES['foto'.$i.'varianti']['name']; // Set $url To Equal The Filename For Later Use 
if ($_FILES['foto'.$i.'varianti']['type'] == "image/jpg" || $_FILES['foto'.$i.'varianti']['type'] == "image/jpeg" || $_FILES['foto'.$i.'varianti']['type'] == "image/pjpeg") { 
$file_ext strrchr($_FILES['foto'.$i.'varianti']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php 
$copy copy($_FILES['foto'.$i.'varianti']['tmp_name'], "$idir$_FILES['foto'.$i.'varianti']['name']); // Move Image From Temporary Location To Permanent Location 
if ($copy) { // If The Script Was Able To Copy The Image To It's Permanent Location 
print '. <font color="#FFFFFF">';// Was Able To Successfully Upload Image 
$simg imagecreatefromjpeg("$idir$url); // Make A New Temporary Image To Create The Thumbanil From 
$currwidth imagesx($simg); // Current Image Width 
$currheight imagesy($simg); // Current Image Height 
if ($currheight $currwidth) { // If Height Is Greater Than Width 
$zoom $twidth $currheight// Length Ratio For Width 

$newheight $theight// Height Is Equal To Max Height 
$newwidth $currwidth $zoom// Creates The New Width 
} else { // Otherwise, Assume Width Is Greater Than Height (Will Produce Same Result If Width Is Equal To Height) 
$zoom $twidth $currwidth// Length Ratio For Height 
$newwidth $twidth// Width Is Equal To Max Width 
$newheight $currheight $zoom// Creates The New Height 

$dimg imagecreate($newwidth$newheight); // Make New Image For Thumbnail 
imagetruecolortopalette($simgfalse256); // Create New Color Pallete 
$palsize ImageColorsTotal($simg); 
for (
$i 0$i $palsize$i++) { // Counting Colors In The Image 
$colors ImageColorsForIndex($simg$i); // Number Of Colors Used 
ImageColorAllocate($dimg$colors['red'], $colors['green'], $colors['blue']); // Tell The Server What Colors This Image Will Use 

imagecopyresized($dimg$simg0000$newwidth$newheight$currwidth$currheight); // Copy Resized Image To The New Image (So We Can Save It) 
imagejpeg($dimg"$tdir$url); // Saving The Image 
imagedestroy($simg); // Destroying The Temporary Image 
imagedestroy($dimg); // Destroying The Other Temporary Image 
print 'Prodotto inserito con SUCCESSO <font color="#FFFFFF">'// Resize successful 
} else { 
print 
'<font color="#FFFFFF">Errore riprova ad inserire il prodotto</font>'// Error Message If Upload Failed 

} else { 
print 
'<font color="#FFFFFF">ERRORE puoi inserire solo file che hanno questa estensione (.jpg or .jpeg. la tua è '// Error Message If Filetype Is Wrong 
print $file_ext// Show The Invalid File's Extention 
print '.</font>'