Visualizzazione dei risultati da 1 a 3 su 3

Discussione: getimagesize()

  1. #1
    Utente di HTML.it L'avatar di Reiko81
    Registrato dal
    Oct 2009
    Messaggi
    203

    getimagesize()

    Ciao a tutti!

    Avrei bisogno di ricavare, da un file immagine passato da un form, altezza-larghezza-tipo.
    Ho trovato in internet info su getimagesize, ma quando lo provo dandogli il nome e il percorso del file (es. immagini/picopallino.gif) mi da tutte le info precise... quando provo a passargli l'immagine da un form, mi da questo tipo di errore:
    Warning: getimagesize() expects parameter 1 to be string, array given in C:\xampp\htdocs\iken\cms\test\get_size.php on line 14


    Il codice del forum è questo
    Codice PHP:
    <form action="get_size.php" method="POST" enctype="multipart/form-data" name="offerta" id="offerta">
    <
    table border="0">
      <
    tr>
        <
    td colspan="2" valign="top"><h2>Inserisci una nuova immagine</h2></td>
        </
    tr>
      <
    tr>
        <
    td valign="top">Immagine</td>
        <
    td valign="top"><input type="file" name="imgUp" id="imgUp" /></td>
      </
    tr>
      <
    tr>
        <
    td colspan="2" valign="top">
            <
    input type="hidden" name="CONTROL" id="CONTROL" value="OK" />
            <
    input type="submit" name="Salva" id="Salva" value="Salva" />
        </
    td>
      </
    tr>
    </
    table>
    </
    form
    quello della pagina get_size.php è questo
    Codice PHP:
    <?php

    if ((isset($_POST["CONTROL"])) && ($_POST["CONTROL"] == "OK")) {
    $file $_FILES["imgUp"];
            if(
    $file["name"] != ""){
            list(
    $width$height$type$attr) = getimagesize($file);
            echo 
    "Image width " .$width;
            echo 
    "
    "
    ;
            echo 
    "Image height " .$height;
            echo 
    "
    "
    ;
            echo 
    "Image type " .$type;
            echo 
    "
    "
    ;
            echo 
    "Attribute " .$attr;
            }else{
                echo 
    "Errore";
                }
    }
    ?>
    La linea 14 è questa:
    list($width, $height, $type, $attr) = getimagesize($file);

    Potete aiutarmi a capire dove sbaglio?

  2. #2
    Utente di HTML.it L'avatar di Reiko81
    Registrato dal
    Oct 2009
    Messaggi
    203
    Ho aggiunto name alla variabile "file"
    Codice PHP:
    $file $_FILES["imgUp"]["name"]; 
    e ho visto che se faccio l'echo di "file" almeno il nome del file esce...

    L'errore però è cambiato in:
    Warning: getimagesize(6960347631ee3725bc0a594a95b402f2.jpg) [function.getimagesize]: failed to open stream: No such file or directory in C:\xampp\htdocs\cms\test\get_size.php on line 15

    Correggetemi se sbaglio... la variabile file ora è una stringa di testo, non un'immagine, giusto?
    E' questo il motivo per il quale getimagesize non funziona?

  3. #3
    Utente di HTML.it L'avatar di Reiko81
    Registrato dal
    Oct 2009
    Messaggi
    203
    Risolto!
    Invece di "name" dovevo mettere "tmp_name"!

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.