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

    Domanda veloce!(Upload file)

    Ciao a tutti,
    sto provando a creare uno script per l'upload simultaneo di piu file su un sito.
    Il form dal quale derivano i dati quindi presenta 5 input type="file" con nomi diversi.

    Non riesco a capire perchè a volte mi carica i file e altre volte no...
    Il codice che uso è questo
    Codice PHP:
    if(move_uploaded_file($_FILES['foto_2']['tmp_name'], $cartella_upload.$_FILES['foto_2']['name'])){            
                                    
    chmod($cartella_upload.$_FILES['foto_2']['name'],0777); //permessi per poterci sovrascrivere/scaricare
                                    
    $check_up_2='ok';    
                                     } 
    ho provato a fare gli echo di $_FILES['foto_2']['tmp_name'] e $_FILES['foto_2']['name'] e ho notato che quando il file non viene inserito anche $_FILES['foto_2']['tmp_name'] non viene visualizzato mentre $_FILES['foto_2']['name'] si.

    Qualcuno sa dirmi quale puo essere il problema? grazie a tutti cmq

  2. #2
    Posta la form di upload ed il risultato di questo codice:

    Codice PHP:
    <?php var_dump($_FILES); ?>

  3. #3
    il risultato del codice è questo:
    Codice PHP:
    array(5) { ["foto_1"]=>  array(5) { ["name"]=>  string(12"DSC01977.JPG" ["type"]=>  string(0"" ["tmp_name"]=>  string(0"" ["error"]=>  int(1) ["size"]=>  int(0) } ["foto_2"]=>  array(5) { ["name"]=>  string(0"" ["type"]=>  string(0"" ["tmp_name"]=>  string(0"" ["error"]=>  int(4) ["size"]=>  int(0) } ["foto_3"]=>  array(5) { ["name"]=>  string(0"" ["type"]=>  string(0"" ["tmp_name"]=>  string(0"" ["error"]=>  int(4) ["size"]=>  int(0) } ["foto_4"]=>  array(5) { ["name"]=>  string(0"" ["type"]=>  string(0"" ["tmp_name"]=>  string(0"" ["error"]=>  int(4) ["size"]=>  int(0) } ["foto_5"]=>  array(5) { ["name"]=>  string(0"" ["type"]=>  string(0"" ["tmp_name"]=>  string(0"" ["error"]=>  int(4) ["size"]=>  int(0) } } 
    mentre il form:
    Codice PHP:
    <form action="index.php?page=aggiungi_foto.php" method="post" enctype="multipart/form-data" name="form1">
    <table align="center">

        <tr valign="baseline">
        <td nowrap align="right">Descrizione:</td>
        <td><input type="hidden" name="id_album" value="<?php echo $_GET['id_album'];?>" size="32"></td>
        </tr>
        <tr valign="baseline">
        <td nowrap align="right">Foto</td>
        <td> <input name="foto_1" type="file" ></td>
        </tr>
            <tr valign="baseline">
        <td nowrap align="right">Foto</td>
        <td> <input name="foto_2" type="file" ></td>
        </tr>
            <tr valign="baseline">
        <td nowrap align="right">Foto</td>
        <td> <input name="foto_3" type="file" ></td>
        </tr>
            <tr valign="baseline">
        <td nowrap align="right">Foto</td>
        <td> <input name="foto_4" type="file" ></td>
        </tr>
            <tr valign="baseline">
        <td nowrap align="right">Foto</td>
        <td> <input name="foto_5" type="file" ></td>
        </tr>
        <tr valign="baseline">
        <td nowrap align="right"></td>
        <td><input type="submit" value="Inserisci Foto"></td>
        </tr>

    </table>

    <input type="hidden" name="MAX_FILE_SIZE" value="30000">
    <input type="hidden" name="CHECK" value="ok">
    </form>

  4. #4
    Utilizza un check tipo if (file_exists($_FILES['foto_2']['tmp_name'] ) && move_uploaded_file(...))

  5. #5
    ma $_FILES['foto_2']['tmp_name'] facendo gli echo non manda a video nulla...è vuoto!

  6. #6

  7. #7
    esatto...fallirà...ma non capisco perchè $_FILES[][tmp_name] è vuoto...mentre ["name"]=> string(12) "DSC01977.JPG" evidentemente no...

    mi sorge il dubbio che sia sbagliato qlcs nel form...o che l'upload di piu file si debba gestire in modo diverso... :master:
    non saprei...

  8. #8
    Il tuo upload ha sollevato un error = 1, ovvero UPLOAD_ERR_INI_SIZE
    Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.

  9. #9
    si... ...il problema era proprio quello...l'immagine era troppo grande x le impostazioni di php...
    Grazie mille per l'aiuto...

    PS: come si fa a vedere l'errore associato ad ogni numero?(es. questo caso error = 1 quindi UPLOAD_ERR_INI_SIZE
    Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini)

  10. #10

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 © 2025 vBulletin Solutions, Inc. All rights reserved.