giorno a tutti ..
ho questo script con un pò di problemi:
Codice PHP:
<?php
/*Upload files directory*/
$up_dir = $_SERVER['DOCUMENT_ROOT'] . "/Upload/up_files";
/*New name upload file*/
$new_name = "1";
/*new_name = "" => new_name = up_file_name*/
$file_name = ($new_name) ? $new_name : $_FILES["upfile"]["name"];
@is_uploaded_file($_FILES["upfile"]["tmp_name"]);
@move_uploaded_file($_FILES["upfile"]["tmp_name"], "$upload_dir/$new_name");
switch ($_FILES["upfile"]["error"])
{
case UPLOAD_ERR_OK:
/*throw new exception("Upload terminato correttamente.");*/
break;
case UPLOAD_ERR_INI_SIZE:
throw new exception("Il file che si è tentato di caricare è troppo grande!");
break;
case UPLOAD_ERR_FORM_SIZE:
throw new exception("Il file che si è tentato di caricare è troppo grande!");
break;
case UPLOAD_ERR_PARTIAL:
throw new exception("Il file è stato caricato solo parzialmente. Riprova.");
break;
case UPLOAD_ERR_NO_FILE:
throw new exception("Non è stato caricato alcun file!");
break;
case UPLOAD_ERR_NO_TMP_DIR:
throw new exception("Errore interno. È stata inviata una segnalazione automatica");
break;
case UPLOAD_ERR_CANT_WRITE:
throw new exception("Tentativo di scrittura del file fallito. Riprova.");
break;
default:
throw new exception("Errore sconosciuto.");
}
?>
1. Penso che il controllo switch non sia ben collegato al resto dello script e non so come poter risolvere il problema.
2. Nel
Codice PHP:
case UPLOAD_ERR_OK:
/*throw new exception("Upload terminato correttamente.");*/
break;
non mi accetta 'throw new exception("Upload terminato correttamente.");' riportandomi
un errore:
Fatal error: Uncaught exception 'Exception' with message 'Upload terminato correttamente.' in C:\www\Upload\upload.php:37 Stack trace: #0 {main} thrown in C:\www\Upload\upload.php on line 37
3. Se commento 'throw new exception("Upload terminato correttamente.");' non mi esce
più nessun errore; però i file non vengono caricati .. perchè??