php - Edit profile picture dont safe the image path in the database -


i want, user can change profile pictures, code dont save image-path in database. uploading image , connection works.

here code:

function pbchange(){ $csrf = length(isset($_post['csrf']) ? $_post['csrf'] : '', 32);     $pbch = length(isset($_post['pbchange']) ? $_post['pbchange'] : '', 1); $error = '';     $name = $_files['file']['name'];     $target_dir = "upload/";     $target_file = $target_dir . basename($_files["file"]["name"]);      // select file type     $imagefiletype = strtolower(pathinfo($target_file,pathinfo_extension));      // valid file extensions     $extensions_arr = array("jpg","jpeg","png","gif");  if($pbch == 1 && $csrf == $_session['csrftoken']){                                                     // check extension                                                 if( in_array($imagefiletype,$extensions_arr) ){                                                      // convert base64                                                      $image_base64 = base64_encode(file_get_contents($_files['file']['tmp_name']) );                                                     $image = 'data:image/'.$imagefiletype.';base64,'.$image_base64;                                                       $query = mysqli_query("update na_user set pb=".$image." id = '".userout('id')."'");                                                      // upload file                                                     move_uploaded_file($_files['file']['tmp_name'],'upload/'.$name);                                                  }                     if($query){                         header('location: ./?p=usersettings&h=pbchange');                         exit;                     } else {                         $error = 'fehler beim ändern des profilbild! bitte versuchen sie es zu einem späteren zeitpunkt erneut.';                         errormail('mysql fehler in "profilbild ändern", funktion "pbchange()"');                     }     } return sondertext($error); 

}


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -