Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Errore upload di file su server Tiscali

    Salve ho un dominio su server Tiscali e ho problemi con uno script di upload di file.
    Ecco il codice della pagina dove è contenuto un semplice form html:

    <form action="upload.php" method="post" ENCTYPE="multipart/form-data">
    File to upload:<input type="file" size=40 name="userfile">


    La dimensione del file d'immagine non deve superare i 2.000.000 Byte

    <input type="submit" value="upload">
    </form>

    La pagina upload.php ha questo codice:

    <?php
    // Declare variables
    // Get the basic file information
    function file_error_return($error) {
    switch($error) {
    case 1 : $output = "The uploaded file exceeds the upload_max_filesize directive in php.ini.
    ";break;
    case 2 : $output = "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
    ";break;
    case 3 : $output = "The uploaded file was only partially uploaded.
    ";break;
    case 4 : $output = "No file was uploaded.
    ";break;
    case 6 : $output = "Missing a temporary folder.
    ";break;
    case 7 : $output = "Failed to write file to disk.
    ";break;
    case 8 : $output = "File upload stopped by extension.
    ";break;
    default: $output = "";
    }
    return $output;
    }

    $userfile = $_FILES['userfile']['name'];
    $file_size = $_FILES['userfile']['size'];
    $file_temp = $_FILES['userfile']['tmp_name'];
    $file_err = $_FILES['userfile']['error'];
    echo "File ".$userfile;
    $path = '/home/web/piccolomondoantico-rc.it/website/uploaddir/';

    // Create a new file name
    // This is so if other files on the server have the same name, it will be renamed
    $randomizer = rand(0000, 9999);
    $file_name = $randomizer.$userfile;

    // Get the file type
    // Using $_FILES to get the file type is sometimes inaccurate, so we are going
    // to get the extension ourselves from the name of the file
    // This also eliminates having to worry about the MIME type
    $file_type = $userfile;
    $file_type_length = strlen($file_type) - 3;
    $file_type = substr($file_type, $file_type_length);

    if(!empty($userfile)) {
    echo '<div style="font-weight: bold; padding: 6px;">File Uploaded Information</div>
    <ul>[*]Original File Name: ' .$userfile. '[*]New File Name: ' .$file_name. '[*]File Type: ' .$file_type.'[*]File Size: ' .$file_size. '[*]File Temporary Name: ' .$file_temp. '[*]Fille Error: ' . $file_err. '

    [/list]';
    echo file_error_return($file_err); // non restituisce nulla se va a buon fine


    // limit the size of the file to 2000000 Byte
    if($file_size > 2000000) {
    echo 'FILE SIZE TO LARGE
    ';
    exit();
    }

    // Set allowed file types
    // Set case of all letters to lower case
    $file_type = strtolower($file_type);
    $files = array();
    $files[] = 'jpeg';
    $files[] = 'jpg';
    $files[] = 'gif';
    $files[] = 'png';
    // Search the array for the allowed file type
    $key = array_search($file_type, $files);
    if($key) {
    echo 'File allowed!
    ';
    } else {
    echo 'ILLEGAL FILE TYPE
    ';
    exit();
    }

    // Check for errors and upload the file
    $percorso=$path.$file_name;
    echo "Nome file compreso di percorso: ".$percorso;
    if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
    echo "
    Copia nella cartella temporanea riuscita";
    if(move_uploaded_file($_FILES['userfile']['tmp_name'], $percorso)) {
    echo '<h3>Upload Successful!</h3>';
    } else {
    echo '<h3>ERRORE</h3>';
    }
    }
    else {
    echo "
    Copia nella cartella temporanea non riuscita";

    }
    } else {
    echo '<h3>No file has been selected.</h3>';
    }
    ?>

    In pratica l'errore è dovuto all'impossilbilità di scrivere nella cartella temporanea.
    Premetto che la cartella in cui andranno copiati i file ha i permessi di scrittura attivati.
    Potete provare lo script a questo link:

    http://www.piccolomondoantico-rc.it/...oader/form.htm

    Lo stesso codice su sever aruba funziona correttamente.

    Come devo fare?

  2. #2

  3. #3
    Salve,
    anch'io ho lo stesso tipo di problema.
    Nonostante i vari tentativi non riesco a far funzionare la cosa che invece funziona benissimo su altri server.
    Qualcuno ha capito il perchè non va?

    Grazie.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.