View Full Version : PHP script che permette di uplodare file in una specifica directory
Manson666
02-02-2004, 18:55
Mi servirebbe uno script php che permetta di upplodare dei file in una particolare directory che si trova nel mio spazio web....qualcuno ha qualcosa di simile?
texerasmo
03-02-2004, 11:02
eccolo..
<?php
if ($HTTP_POST_VARS['submit']) {
print_r($HTTP_POST_FILES);
if (!is_uploaded_file($HTTP_POST_FILES['file']['tmp_name'])) {
$error = "IMMAGINE NON AGGIORNATA SUL SERVER!";
unlink($HTTP_POST_FILES['file']['tmp_name']);
// assign error message, remove uploaded file, redisplay form.
} else {
//a file was uploaded
$maxfilesize=80240;
if ($HTTP_POST_FILES['file']['size'] > $maxfilesize) {
$error = "FILE TROPPO GRANDE";
}else{
// if ($HTTP_POST_FILES['file']['type'] != "image/gif" AND $HTTP_POST_FILES['file']['type'] != "image/pjpeg") {
// $error = "QUESTA IMMAGINE NON é VALIDO";
// unlink($HTTP_POST_FILES['file']['tmp_name']);
// assign error message, remove uploaded file, redisplay form.
//} else {
//File has passed all validation, copy it to the final destination and remove the temporary file:
copy($HTTP_POST_FILES['file']['tmp_name'],"/Programmi/Apache Group/Apache2/htdocs/AIA/test/".$HTTP_POST_FILES['file']['name']);
unlink($HTTP_POST_FILES['file']['tmp_name']);
print "OK PUOI UTILIZZARE QUESTA IMMAGINE NEL TUO ARTICOLO!";
//}
}
}
}
?>
<html>
<head></head>
<body>
<form action="<?=$PHP_SELF?>" method="post" enctype="multipart/form-data">
<?=$error?>
<br><br>
Choose a file to upload:<br>
<input type="file" name="file"><br>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
ma mettere il codice
qua dentro (tag [ code][ /code], senza spazi ovviamente)
pare brutto?
texerasmo
03-02-2004, 13:26
copy($HTTP_POST_FILES['file']['tmp_name'],"/Programmi/Apache Group/Apache2/htdocs/AIA/test/".$HTTP_POST_FILES['file'][
Dove c'è questa riga di codice ci metti la tua dir quindi sostituisci
/Programmi/Apache Group/Apache2/htdocs/AIA/test/
con la il tuo path per la tua dir.
la / iniziale rappresenta la root del tuo sistema
poi puoi migliorare il cod come vuoi....:)
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.