Pagina "config.php

<?php
$dir_upload="../admin/gallery/"; // DIRECTORY DOVE EFFETTUARE L'UPLOAD
$chmod_dir=0700; // PERMESSI DELLA DIRECTORY
$debug=0; // 1=STAMPA ALCUNE SEMPLICI INFORMAZIONI DI DEBUG, 0=NON STAMPARE
$sovrascrivi_file=0; // 1=SOVRASCRIVI I FILES SE ESISTENTI, 0=NON SOVRASCRIVERE I FILES
$dim_massima=10000; // DIMENSIONE MASSIMA UPLOAD IN KB
$check_tipi=1; //1=CONTROLLA IL TIPO DI FILE, 0=NON CONTROLLARE
$tipi_permessi=array( //ARRAY PER ALCUNI TIPI DI FILE
"text/plain","text/html","text/xml",
"image/jpeg",
"image/pjpeg",
"image/gif",
"image/png",
);
?>

-------------------------------------------
Nome pagina "upload.class.php

<?php
// file upload.class.php
//
// Marco Barcaro
// 27/12/2004
// Testato con Apache 1.3.29, PHP 4.3.10, su winXP
// Testato con Apache 1.3.26, PHP 4.1.2, su Debian

$dir_upload=(substr($dir_upload,-1) != "/" && $dir_upload != "") ? $dir_upload."/" : $dir_upload;
define("DIR_UPLOAD",$dir_upload);
define("CHMOD_DIR",$chmod_dir);
define("DEBUG",$debug);
define("SOVRASCRIVI_FILE",$sovrascrivi_file);
define("DIM_MASSIMA",$dim_massima*1024);
define("CHECK_TIPI",$check_tipi);
define("TIPI_PERMESSI",implode("|",$tipi_permessi) );

class upload {
function upload(){
}

function caricafile(){
//CODICE PER L'UPLOAD CON VARI CONTROLLI
if (count($_FILES) > 0){
$numero_file= count($_FILES['file']['tmp_name']);
for($i=0;$i<$numero_file;$i++){
if($_FILES['file']['size'][$i] == 0){
echo "L'UPLOAD DEL FILE {$_FILES['file']['name'][$i]} NON E' ANDATO A BUON FINE!
\n";
unset( $_FILES['file']['name'][$i]);
unset( $_FILES['file']['type'][$i]);
unset( $_FILES['file']['size'][$i]);
unset( $_FILES['file']['error'][$i]);
unset( $_FILES['file']['tmp_name'][$i]);
}
}
$numero_file=count( $_FILES['file']['tmp_name']);
echo "Hai caricato $numero_file file(s)";
echo "

\n";
foreach($_FILES['file']['name'] as $chiave=>$valore){
if (DEBUG == 1){
echo "Nome file: ".$_FILES['file']['name'][$chiave]."
\n";
echo "Tipo file: ".$_FILES['file']['type'][$chiave]."
\n";
echo "Dimensione: ".$_FILES['file']['size'][$chiave]." byte
\n";
echo "Nome temporaneo: ".$_FILES['file']['tmp_name'][$chiave]."
\n";
}
if (is_uploaded_file( $_FILES['file']['tmp_name'][$chiave])){
if ($_FILES['file']['size'][$chiave] <= DIM_MASSIMA){
if(CHECK_TIPI == 0 || (CHECK_TIPI == 1 && in_array( $_FILES['file']['type'][$chiave], explode("|",TIPI_PERMESSI)))){
if(!is_dir(DIR_UPLOAD) && DIR_UPLOAD != ""){
if( !@mkdir(DIR_UPLOAD,CHMOD_DIR))
die("ERRORE NELLA CREAZIONE DELLA DIRECTORY ".DIR_UPLOAD."");
}
if(!file_exists(DIR_UPLOAD.$_FILES['file']['name'][$chiave]) || SOVRASCRIVI_FILE == 1){
if (@move_uploaded_file( $_FILES['file']['tmp_name'][$chiave], DIR_UPLOAD.$_FILES['file']['name'][$chiave]))
echo "FILE {$_FILES['file']['name'][$chiave]} TRASFERITO! ";
else
die("ERRORE NEL TRASFERIMENTO DEL FILE ".$_FILES['file']['name'][$chiave]."");
} else
echo ("IL FILE ".$_FILES['file']['name'][$chiave]." E' ESISTENTE!");
} else
echo ("IL TIPO DI FILE ".$_FILES['file']['type'][$chiave]." NON E' CONSENTITO!");
} else
echo ("LA DIMENSIONE DEL FILE ".$_FILES['file']['type'][$chiave]." NON E' CONSENTITA!");
} else
die("ERRORE NEL TRASFERIMENTO DEL FILE ".$_FILES['file']['name'][$chiave]."");
echo "<hr />\n";
}
}
}

function mostraform(){
//FORM PER EFFETTUARE L'UPLOAD
echo "<html>
<head>
<script type=\"text/javascript\" src=\"esterno.js\"></script>
</head>
<body>
<form action=\"{$_SERVER['PHP_SELF']}\" method=\"POST\" name=\"modulo\" enctype=\"multipart/form-data\">
<div id=\"attachment\" style=\"display:none\">
<input id=\"file\" name=\"file\" type=\"file\" size=\"55\" />
<a href=\"#\" onclick=\"javascript:removeFile(this.parentNode.pa rentNode,this.parentNode);\"> Rimuovi</a>
</div>
<div id=\"attachments\">

<a id=\"addupload\" href=\"javascript:addUpload('file')\">Aggiungi file</a>


<input name=\"file[]\" type=\"text\" size=\"55\" />
<input name=\"file[]\" type=\"file\" size=\"55\" />
<span id=\"attachmentmarker\"></span>
</div>
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"".DIM_MASSIMA."\" />
<input type=\"submit\" value=\"invia\" />
</form>
</body>
</html>\n";
}
}
?>
-----------------------------------------------------------
questo è il codice per caricare i file che ho trovato nel forum insieme allo script "esterno.php":

var max = 0; // maximum # of attachments allowed
var currentUploads = 0; // current # of attachment sections on the web page
var nameDesc = ''; // Name property for the Description Input field
var nameFile = ''; // Name property for the File Input field
var scrollPosVert = 0; // stores the current scroll position on the form

// for some reason when a div is taken out, the form
// will scroll to the top on both Firefox and IE

// SCROLL FUNCTIONS
function saveScrollPos(offset){
scrollPosVert=(document.all)?document.body.scrollT op:window.pageYOffset-offset;
}

function setScrollPos(){
window.scrollTo(0, scrollPosVert);
setTimeout('window.scrollTo(0, scrollPosVert)',1);
}


// This function adds a new attachment section to the form
// It is called when the user clicks the "Attach a file" button...
// It takes three arguments:
// maxUploads - the maximum number of attachments allowed
// descFieldName - the field name for the Description Input field
// fileFieldName - the field name for the File Input field
function addUpload(fileFieldName){
nameFile=fileFieldName;
currentUploads++;
if (currentUploads>9) return;
if (currentUploads>0)
document.getElementById('addupload').childNodes[0].data='Aggiungi file';
// First, clone the hidden attachment section
var newFields = document.getElementById('attachment').cloneNode(tr ue);
newFields.id = '';
// Make the new attachments section visible
newFields.style.display = 'block';
// loop through tags in the new Attachment section
// and set ID and NAME properties
//
// NOTE: the control names for the Description Input
// field and the file input field are created
// by appending the currentUploads variable
// value to the nameFile and nameDesc values
// respectively
//
// In terms of Xaraya, this means you'll need to name your
// DD properties will need names like the following:
// "AttachmentDesc1"
// "AttachmentFile1"
// "AttachmentDesc2"
// "AttachmentFile2"
// "AttachmentDesc3"
// "AttachmentFile3"
// et cetera...
var newField = newFields.childNodes;
for (var i=0;i<newField.length;i++){
if (newField[i].name==nameFile){
newField[i].id=nameFile+currentUploads;
newField[i].name=nameFile+'[]';
//newField[i].name=nameFile+currentUploads;
}
}
// Insert our new Attachment section into the Attachments Div
// on the form...
var insertHere = document.getElementById('attachmentmarker');
insertHere.parentNode.insertBefore(newFields,inser tHere);
}



// This function removes an attachment from the form
// and updates the ID and Name properties of all other
// Attachment sections
function removeFile(container, item){
// get the ID number of the upload section to remove
var tmp = item.getElementsByTagName('input')[0];
var basefieldname = '';
basefieldname = nameFile;
var iRemove=Number(tmp.id.substring(basefieldname.leng th, tmp.id.length));
// Shift all INPUT field IDs and NAMEs down by one (for fields with a
// higher ID than the one being removed)
var x = document.getElementById('attachments').getElements ByTagName('input');
for (i=0;i<x.length;i++){
basefieldname=nameFile;
var iEdit = Number(x[i].id.substring(basefieldname.length, x[i].id.length));
if (iEdit>iRemove){
x[i].id=basefieldname+(iEdit-1);
x[i].name=basefieldname+(iEdit-1);
}
}

// Run through all the DropCap divs (the number to the right of the attachment
// section) and update that number...
x=document.getElementById('attachments').getElemen tsByTagName('div');
for (i=0;i<x.length;i++){
// Verify this is actually the "dropcap" div
if (x[i].id.substring(0, String('dropcap').length)=='dropcap'){
ID = Number(x[i].id.substring(String('dropcap').length, x[i].id.length));
// check to see if current attachment had a higher ID than the one we're
// removing (and thus needs to have its ID dropped)
if (ID>iRemove){
x[i].id='dropcap'+(ID-1);
x[i].childNodes[0].data=(ID-1);
}
}
}

currentUploads--;
saveScrollPos(0);
container.removeChild(item);
setScrollPos();
document.getElementById('addupload').style.visibil ity='visible';
if (currentUploads==0)
document.getElementById('addupload').childNodes[0].data='Aggiungi file';
}

Ora devo passare i dati in questa pagina che ho creato
nome pagina "insert.php" che va ad inserire tutto nel db

<?
include ("config.inc.php");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Inserimento recensione</title>
</head>
<body>
<table width="100%" >
<tr width="40px"><td height="79" ></td>
</tr>
<tr><td>
<h1 class="Stile1">Inserisci moto </h1>

<form method=post action= save.php>


* Nome: <input type="text" size=40 name="nome">

(Sarà visualizzato nella recensione insiame al modello)</p>


* Cogmome:
<input type="text" size="40" name="cogmome" />


(Non sar&agrave; visualizzato nella recensione)



*Modello:
<input type="text" size="40" name="modello" />
</p>




*Marca:
<select name="moto">
<option value="APRILIA">APRILIA</option>
<option value="BENELLI">BENELLI</option>
<option value="BETA">BETA</option>
<option value="BMW">BMW</option>
<option value="CAGIVA">CAGIVA</option>
<option value="DERBI">DERBI</option>
<option value="DUCATI">DUCATI</option>
<option value="GILERA">GILERA</option>
<option value="HARLEY DAVIDSON">HARLEY DAVIDSON</option>
<option value="HM">HM</option>
<option value="HONDA">HONDA</option>
<option value="ITALJET">ITALJET</option>
<option value="KAWASAKI">KAWASAKI</option>
<option value="KTM">KTM</option>
<option value="MALAGUTTI">MALAGUTTI</option>
<option value="MBK">MBK</option>
<option value="MOTOGUZZI">MOTOGUZZI</option>
<option value="MORINI">MORINI</option>
<option value="PEUGEOT">PEUGEOT</option>
<option value="20">PIAGGIO</option>
<option value="SUZUKI">SUZUKI</option>
<option value="TM">TM</option>
<option value="TRIUNPH">TRIUNPH</option>
<option value="VESPA">VESPA</option>
<option value="YAMAHA">YAMAHA</option>
<option value="ALTRO">ALTRO</option>
</select>
</p>






Titolo della recensione:
<input type="text" size="40" name="anteprimaDescrizione" />
</p>




Descrizione:
<textarea name="descrizione" cols="60"></textarea>
</p>






mail:
<input type="text" size="40" name="mail" />

(per avvisarti dell'avvenuto inserimento al link)</p>





Allega le foto:</p>



Foto 01: <input name="foto_01" type="text">
Foto 02: <input name="foto_02" type="text">
Foto 03: <input name="foto_03" type="text">
Foto 04: <input name="foto_04" type="text">
Foto 05: <input name="foto_05" type="text">
Foto 06: <input name="foto_06" type="text">
Foto 07: <input name="foto_07" type="text">
Foto 08: <input name="foto_08" type="text">
Foto 09: <input name="foto_09" type="text">
Foto 10: <input name="foto_10" type="text">



<input type=submit value=invia>
</p>
</p>

</form></td>
</tr>
</table>



</body>
</html>

Spero di farti capire !!!