carica foto profilo sessione utente

  • Creatore Discussione Creatore Discussione Imperor
  • Data di inizio Data di inizio

Imperor

Utente Attivo
25 Nov 2010
102
2
18
Roma
www.fcfclean.it
buongiorno quando l'utente loggato voglia cambiare la sua foto profilo vorrei che la foto viene salvata con il nome utente per esempio se l'utente francesco cambia la sua foto la dovrebbe salvare come francesco.jpg o jpeg - png - gif posto il codice se qualcuno può aiutarmi grazie
Codice:
if(isset($_FILES['image'])){
                                      $errors= array();
                                      $file_name = $_FILES['image']['name'];
                                      $file_size = $_FILES['image']['size'];
                                      $file_tmp = $_FILES['image']['tmp_name'];
                                      $file_type = $_FILES['image']['type'];
                                      $array = explode('.',$_FILES['image']['name']);
                                      $file_ext=strtolower(end($array)); // Now a variabl
                                
                                      $extensions= array("jpeg","jpg","png");
                                
                                      if(in_array($file_ext,$extensions)=== false){
                                         $errors[]="extension not allowed, please choose a JPEG or PNG file.";
                                      }
                                
                                      if($file_size > 2097152) {
                                         $errors[]='File size must be 2 MB';
                                      }
                                      
                                    
                                
                                      if(empty($errors)==true) {
                                         move_uploaded_file($file_tmp,"uploads/".$file_name);
                                        
                                        
                                
                                        $store=mysqli_query($conn,"UPDATE users SET foto='$file_name' WHERE username='$username'");
                                        mysqli_query($conn,$store);
                                         echo "Success";
                                      }else{
                                         print_r($errors);
                                         echo"it failed";
                                      }
                                   }
 
buonasera non mi serve + rinominare la foto :) ma ho un problema sicuramente il motivo è che sto usando dei vecchi codici ma il codice del post sopra funziona cambia la foto profilo ma mi da il seguente errore: come posso risolvere?
-------------------------------------------------------------------------------------------------------------------------

Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1' at line 1 in C:\xampp\htdocs\sito\test.php:129 Stack trace: #0 C:\xampp\htdocs\sito\test.php(129): mysqli_query(Object(mysqli), '1') #1 {main} thrown in C:\xampp\htdocs\sito\test.php on line 129
 

Discussioni simili