Visualizza messaggio singolo
Vecchio 05-04-2006, 22.56.33   #2
quipo.it
WT Assistant
 
L'avatar di quipo.it
 
Registrato: 19-12-2000
Loc.: Cambiano (Torino)
Messaggi: 591
quipo.it promette bene
Codice:
<table>
<form action="OperazioniFile.php" method="post" enctype="multipart/form-data">
<tr>
<td>Scegli il db sul quale vuoi fare il back-up</td>
</tr>
<td><b>Operazione</b></td>
<td><INPUT type="file" name="scelta"></td>
</tr>
<tr>
<td><INPUT type="submit" value="Vai avanti"></td>
</tr>
</form>
</table>
[PHP]
<?php
if (file_exists($_FILES['scelta']['tmp_name'])) {
echo "Nome file ->".$_FILES['scelta']['tmp_name']."<br>";
$f = @fopen($_FILES['scelta']['tmp_name'], "r");
while(!feof($f))
{
$riga = fgets($f,4096);
echo "<b>".$riga."</b><br>";
}
} else {
echo "Il file ".$_FILES['scelta']['tmp_name']." non è stato trovato";
}
?>
[/PHP]


intanto è indispensabile mettere enctype="multipart/form-data" se no non fa l'upload. Poi il file viene caricato in una cartella temporanea, e se vuoi salvarlo in una cartella predefinita devi copiarlo:

[PHP]
$save_as = '/destination/path/new_filename.zip';
copy($_FILES['scelta']['tmp_name'], $save_as);
[/PHP]

e comunque l'array su cui devi lavorare è $_FILES e non $_POST.

HTH
___________________________________

There are 10 kinds of people in this world,
those who can read binary and those who can't.

Care to say "thank you"?
quipo.it non è collegato   Rispondi citando