Visualizzazione dei risultati da 1 a 3 su 3

Discussione: upload immagine + dati

  1. #1

    upload immagine + dati

    ciao a tutti
    ho questo codice che mi serve per caricare sulla tabella "utenti" del mio db delle informazioni riguardo agli utenti.
    il problema è che quando carico la foto, nella tabella utenti vedo il percorso della foto, ma la cartella dove dovrebbe finire la foto è vuota!

    <?php
    include('function/config.inc');
    session_start();

    $flag = $_POST['flag'];
    $nome = $_POST['nome'];
    $cognome = $_POST['cognome'];
    $user =$_POST['user'];
    $password = $_POST['password'];
    $mail = $_POST['mail'];
    $ruolo = $_POST['ruolo'];

    if (is_uploaded_file($_FILES['foto']['tmp_name'])) {

    $foto = "../fototeam/".$_FILES['foto']['name'];
    move_uploaded_file($_FILES['foto']['tmp_name'],$foto);
    }
    else { $foto = ""; }

    if ($flag == 99) {

    $query="INSERT INTO utenti (nome,cognome,user,password,mail,ruolo,foto) VALUES ('$nome','$cognome','$user','$password','$mail','$ ruolo','$foto')";

    // echo "QUERY INSERIMENTO: ".$query;

    mysql_query($query,$connessione) or die('Could not connect:' .mysql_error());

    }





    //if (is_uploaded_file($_FILES['foto']['tmp_name'])) {
    // move_uploaded_file($_FILES['foto']['tmp_name'],"/var/www/handcrafted/SitoHand/fototeam/".$_FILES['foto']['name']);
    // move_uploaded_file($_FILES['foto']['tmp_name'],"percorso-cartella-destinazione-foto/".$_FILES['foto']['name']);
    // }

    ?>



    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>

    <title>Inserisci nel team!</title>
    </head>
    <body>
    <center>
    <h1>Inserisci nel team!</h1>




    <form action="inserisciteam2.php" method="post" style="border: medium solid red;"class="modulo" enctype="multipart/form-data">
    <input type="hidden" name="flag" value="99">
    <table border="0" cellspacing="5" cellpadding="6" width="350">
    <tr>
    <td width="150">Nome:</td>
    <td width="200"><input type="text" name="nome"></td>
    </tr>
    <tr>
    <td width="150">Cognome:</td>
    <td width="200"><input type="text" name="cognome"></td>
    </tr>
    <tr>
    <td width="150">User:</td>
    <td width="200"><input type="text" name="user" value=""></td>
    </tr>
    <tr>
    <td width="150">Password:</td>
    <td width="200"><input type="text" name="password" value=""></td>
    </tr>
    <tr>
    <td width="150">E-mail:</td>
    <td width="200"><input type="text" name="mail"></td>
    </tr>
    <tr>
    <td width="150">Ruolo:</td>
    <td width="200"><input type="text" name="ruolo"></td>
    </tr>

    <tr>
    <td width="150">Foto:</td>
    <td width="200"><input type="file" name="foto"></td>
    </tr>


    <tr>
    <td width="150"><input type="reset" value="Svuota Modulo"></td>
    <td width="200"><input type="submit" name="submit" value="Inserisci"></td>
    </tr>
    </table>
    </form>

    </center>
    </body>
    <?php
    mysql_close($connessione);
    ?>
    </html>

  2. #2
    Utente di HTML.it L'avatar di Grino
    Registrato dal
    Oct 2004
    Messaggi
    739
    Hai provato a fare una echo $_FILES['foto']['error']?

    Se diversa da zero vuol dire che hai un errore in fase di upload. Per dettagli sugli errori vedi la pagina

    http://it.php.net/manual/en/features...oad.errors.php
    Siamo sempre troppo gelosi delle nostre grandi piccole opere! - Grino inedito.
    Lavori e Lavoretti

  3. #3
    Utente di HTML.it
    Registrato dal
    Apr 2004
    Messaggi
    3,709
    attiva - se già non lo è - la visualizzazione di errori e warning... se c'è un problema l'interprete dovrebbe segnalartelo (errore nel form, nell'invio, nella scrittura sulla cartella per i permessi o altro)

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.