Salve ragazzi, vi posto il mio problema:
dunque ho una pagina per inserire dei prodotti e uno script trovato in rete per l' upload delle immagini. Ora come potrei unire le due cose? altrimentimenti dovrei prima effettuare l'upload della foto e poi nella pagina di inserimento far e di nuovo l'upload per fagli stampare il path.

Il problema è che i form delle due pagine hanno diversi tipi di "azione"

nella pagina di inserimento prodotti, l'azione è:
<?php echo $editFormAction; ?>

invece nella pagina dell'upload l'azione è:
submit.php?subpage=upload


questa è la pagina di inserimento prodotti:


<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO prodotti (id_menu, codice, titolo, prezzo, foto, foto_thumbs, scheda) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['id_menu'], "text"),
GetSQLValueString($_POST['codice'], "text"),
GetSQLValueString($_POST['titolo'], "text"),
GetSQLValueString($_POST['prezzo'], "double"),
GetSQLValueString($_FILES['foto']['name'], "text"),
GetSQLValueString($_FILES['foto']['name'], "text"),
GetSQLValueString($_POST['scheda'], "text"));

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

mysql_select_db($database_conn, $conn);
$query_rs_menu = "SELECT * FROM menu ORDER BY nome_menu ASC";
$rs_menu = mysql_query($query_rs_menu, $conn) or die(mysql_error());
$row_rs_menu = mysql_fetch_assoc($rs_menu);
$totalRows_rs_menu = mysql_num_rows($rs_menu);

mysql_select_db($database_conn, $conn);
$query_rs_inserisci_prodotto = "SELECT foto, foto_thumbs FROM prodotti";
$rs_inserisci_prodotto = mysql_query($query_rs_inserisci_prodotto, $conn) or die(mysql_error());
$row_rs_inserisci_prodotto = mysql_fetch_assoc($rs_inserisci_prodotto);
$totalRows_rs_inserisci_prodotto = mysql_num_rows($rs_inserisci_prodotto);
?>



questa è la pagina invece che fa l'upload della foto

<?php
$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

if (!isset($_GET['subpage'])) { // Image Upload Form Below ?>
<table width="500" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<th scope="col"><form method="post" action="submit.php?subpage=upload" enctype="multipart/form-data">
File:

<input type="file" name="foto" class="form">



<input name="Carica la foto" type="submit" value="Carica la foto" class="form" id="Carica la foto">
</form>
<? } else if (isset($_GET['subpage']) && $_GET['subpage'] == 'upload') { // Uploading/Resizing Script
$url = $_FILES['foto']['name']; // Set $url To Equal The Filename For Later Use
if ($_FILES['foto']['type'] == "image/jpg" || $_FILES['foto']['type'] == "image/jpeg" || $_FILES['foto']['type'] == "image/pjpeg") {
$file_ext = strrchr($_FILES['foto']['name'], '.'); // Get The File Extention In The Format Of , For Instance, .jpg, .gif or .php
$copy = copy($_FILES['foto']['tmp_name'], "$idir" . $_FILES['foto']['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 'Immagine caricata CORETTAMENTE.
'; // 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($simg, false, 256); // 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, $simg, 0, 0, 0, 0, $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 'miniatura creata correttamente'; // Resize successful
} else {
print '<font color="#FF0000">ERROR: Unable to upload image.</font>'; // Error Message If Upload Failed
}
} else {
print '<font color="#FF0000">ERROR: Wrong filetype (has to be a .jpg or .jpeg. Yours is '; // Error Message If Filetype Is Wrong
print $file_ext; // Show The Invalid File's Extention
print '.</font>';
}
} ?>