Dopo varie ricerche in rete, ho deciso di optare per l'esempio troveto nella guida ufficiale (http://it2.php.net/manual/it/features.file-upload.php)...e neanche questa volta funziona.
Posto i codici
form
- Codice: Seleziona tutto
<FORM METHOD="POST" ACTION="fotografie_aeree_verticali_include.php" enctype="multipart/form-data" name="form1">
<tr height="38">
<td width="400" align="left" height="38" valign="middle">
<br><h5><b>Anno Ripresa:</b><br>
<INPUT name="AnnoRipresa" TYPE="Text"id="AnnoRipresa"></h5>
</td><td><br><h5><b>Foto:</b></h5>
<input type="file" name="Foto" id="Foto"><br><br>
</td>
</tr>
<tr height="38">
<td width="400" align="left" height="38">
<h5><b>Sensore:</b><br>
<INPUT name="Sensore" TYPE="Text"id="Sensore"></h5>
</td>
</tr>
<tr height="53">
<td width="400" align="left" height="53">
<h5><b>Regione:</b><br>
<INPUT name="Regione" TYPE="Text" id="Regione"></h5>
</td>
</tr>
<tr>
<td width="400" align="left">
<h5><b>Provincia:</b><br>
<INPUT name="Provincia" TYPE="Text"id="Provincia"></h5>
</td>
</tr>
<tr>
<td width="400" align="left">
<h5><b>Comprensorio:<br></b>
<INPUT name="Comprensorio" TYPE="Text"id="Comprensorio"></h5>
</td>
</tr>
<tr>
<td width="400" align="left">
<h5><b>Comune:</b><br>
<INPUT name="comune" TYPE="Text"id="comune"></h5>
</td>
</tr>
<tr>
<td width="400" align="left">
<h5><b>Toponimo:</b><br>
<INPUT name="Toponimo" TYPE="Text"id="Toponimo"></h5>
</td>
</tr>
<tr>
<td width="400" align="left">
<h5><b>Tipo Evidenza:</b><br>
<INPUT name="TipoEvidenza" TYPE="Text"id="TipoEvidenza"></h5>
</td>
</tr>
<tr>
<td width="400" align="left">
<h5><b>Attestazione Documentaria:</b><br>
<INPUT name="AttestazioneDocumentaria" TYPE="Text"id="AttestazioneDocumentaria"></h5>
</td>
</tr>
<tr>
<td width="400" align="left">
<h5><b>Interpretazione:</b><br>
<INPUT name="Interpretazione" TYPE="Text"id="Interpretazione"></h5>
</td>
</tr>
<tr>
<td width="400" align="left">
<h5><b>Affidabilità:</b><br>
<INPUT name="Affidabilità" TYPE="Text"id="Affidabilità"></h5>
</td>
</tr>
<tr>
<td width="400" align="left">
<h5><b>Definizione:</b><br>
<INPUT name="Definizione" TYPE="Text"id="Definizione"></h5>
</td>
</tr>
<tr>
<td width="400" align="left">
<h5><b>Cronologia:</b><br>
<INPUT name="Cronologia" TYPE="Text"id="Cronologia"></h5>
</td>
</tr>
<tr>
<td width="400" align="left"><br><h5><INPUT TYPE="SUBMIT" VALUE="Insert"></h5></td>
</tr>
</form>
Questa è la pagina fotografie_aeree_verticali_include.php
- Codice: Seleziona tutto
<?php
$db_host="...";
$db_user="...";
$db_password="...";
$db_database="...";
$connessione=mysql_connect($db_host,$db_user,$db_password) or die ("Errore nella connessione al Mysql:" . mysql_error());
mysql_select_db($db_database,$connessione) or die ("Errore nella selezione del db:" . mysql_error());
$uploaddir = './fotografie';
//fotografie corrisponde alla cartella nella quale vorrei fossero salvate le immagini
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "File is invalid.\n!";
}
print_r($_FILES);
$query = "INSERT INTO fotoaereeverticali (AnnoRipresa, Sensore, Regione, Provincia, Comprensorio, Comune, Toponimo, TipoEvidenza, AttestazioneDocumentaria, Interpretazione, Affidabilità, Definizione, Cronologia, Foto) VALUES
('".$_POST['AnnoRipresa']."', '".$_POST['Sensore']."', '".$_POST['Regione']."', '".$_POST['Provincia']."', '".$_POST['Comprensorio']."', '".$_POST['Comune']."', '".$_POST['Toponimo']."', '".$_POST['TipoEvidenza']."', '".$_POST['AttestazioneDocumentaria']."', '".$_POST['Interpretazione']."', '".$_POST['Affidabilità']."', '".$_POST['Definizione']."', '".$_POST['Cronologia']."', '".$_FILES['upfile'] ['name']."')";
$Result=mysql_query($query) or die ("Errore nella query:" . mysql_error());
echo "Record inserito con successo";
echo $_FILE['upfile']['name'];
?>
E questo è l'errore chee mi da
- Codice: Seleziona tutto
File is invalid. !Array ( [Foto] => Array ( [name] => Intervista CorriereSera.jpg [type] => image/jpeg [tmp_name] => /tmp/phpDanWDa [error] => 0 [size] => 665388 ) ) Record inserito con successo
Qualcuno può aiutarmi