il form è questo:
Codice PHP:
<form action="modifiche_utente/modifica_foto.php" method="post" enctype="multipart/form-data" name="modifica_foto" id="modifica_foto">
<label>
<input name="" type="file" class="Stile1" />
</label>
<label>
<input type="submit" class="Stile1" value="Invia" />
</label>
</form>
modifica_foto.php è questo:
Codice PHP:
......
session_start();
$query = "UPDATE tabella SET foto='" . $_POST['modifica_foto'] . "' WHERE utente ='" . $_SESSION['utente'] . "'";
mysql_query($query);
$target_path = $_SERVER['DOCUMENT_ROOT'] . "/public/foto_utente/";
$target_path = $target_path . basename( $_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
echo "il file ". basename( $_FILES['file']['name']). " è stato caricato";
} else{
echo "c'è stato un errore. riprova!";
}
?>
/public/foto_utente/ è la cartella di destinazione delle foto
l'errore che mi da è questo:
c'è stato un errore. riprova!