RE: [PHP] File upload problem
| From: | Larry Brown | Date: | Sat, 20 Dec 2003 13:06:29 +0000 |
| Subject: | RE: [PHP] File upload problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-173072@lists.php.net to get a copy of this message | ||
According to the documentation you have to have the maxfilesize tag before
the input tag.
-----Original Message-----
From: Dino Costantini [mailto:dino85@katamail.com]
Sent: Wednesday, December 17, 2003 6:34 PM
To: php-general@lists.php.net
Subject: [PHP] File upload problem
i'm trying to write a page which allows user to upload file. theese are my
sources but they didn't work, anyone could help me?
-----form.html--------
<form action="upload.php" method="post"
enctype="multipart/form-data">
<input type="file" name="upfile">
<input type="hidden" name="MAX_FILE_SIZE" value="10000">
<input type="submit" value="Invia il file">
</form>
--------upload.php-----------
<?php
// QUESTE RIGHE RENDONO LO SCRIPT COMPATIBILE CON LE VERSIONI
// DI PHP PRECEDENTI ALLA 4.1.0
if(!isset($_FILES)) $_FILES = $HTTP_POST_FILES;
if(!isset($_SERVER)) $_SERVER = $HTTP_SERVER_VARS;
/********************* VARIABILI DA SETTARE ********************/
// Directory dove salvare i files Uploadati ( chmod 777, percorso assoluto)
$upload_dir = $_SERVER["DOCUMENT_ROOT"] . "/esempi";
// Eventuale nuovo nome da dare al file uploadato
$new_name = "ciao.dino";
// Se $new_name è vuota, il nome sarà lo stesso del file uploadato
$file_name = ($new_name) ? $new_name : $_FILES["upfile"]["name"];
if(trim($_FILES["upfile"]["name"]) == "") {
die("Non hai indicato il file da uploadare !");
}
if(@is_uploaded_file($_FILES["upfile"]["tmp_name"])) {
@move_uploaded_file($_FILES["upfile"]["tmp_name"],
"$upload_dir/$file_name")
or die("Impossibile spostare il file, controlla l'esistenza o i permessi
della directory
dove fare l'upload.");
} else {
die("Problemi nell'upload del file " .
$_FILES["upfile"]["name"]);
}
echo "L'upload del file " . $_FILES["upfile"]["name"] . " è
avvenuto
correttamente";
?>
-----------------------
upload.php doesn't upload anything and doesn't output any error message. i
don't think it's an apache problem, because this is the only page that
doesn't work.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php