bug fix profile picture
This commit is contained in:
parent
859ca4ef52
commit
ccdcba8699
|
@ -242,10 +242,16 @@ $(document).ready(function() {
|
||||||
|
|
||||||
$("#jsprofilePictureInputFile").on("change", function() {
|
$("#jsprofilePictureInputFile").on("change", function() {
|
||||||
|
|
||||||
|
// Data to send via AJAX
|
||||||
|
var username = $("#jsusername").val();
|
||||||
|
var formData = new FormData($("#jsprofilePictureForm")[0]);
|
||||||
|
formData.append('username', username);
|
||||||
|
formData.append('tokenCSRF', tokenCSRF);
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "<?php echo HTML_PATH_ADMIN_ROOT ?>ajax/profile-picture",
|
url: HTML_PATH_ADMIN_ROOT+"ajax/profile-picture",
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: new FormData($("#jsprofilePictureForm")[0]),
|
data: formData,
|
||||||
cache: false,
|
cache: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
processData: false,
|
processData: false,
|
||||||
|
|
|
@ -1,6 +1,19 @@
|
||||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
// $_POST
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// (string) $_POST['username']
|
||||||
|
$username = empty($_POST['username']) ? false : $_POST['username'];
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ($username===false) {
|
||||||
|
exit (json_encode(array(
|
||||||
|
'status'=>1,
|
||||||
|
'message'=>'Error in username.'
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($_FILES['profilePictureInputFile'])) {
|
if (!isset($_FILES['profilePictureInputFile'])) {
|
||||||
exit (json_encode(array(
|
exit (json_encode(array(
|
||||||
'status'=>1,
|
'status'=>1,
|
||||||
|
@ -10,8 +23,6 @@ if (!isset($_FILES['profilePictureInputFile'])) {
|
||||||
|
|
||||||
// File extension
|
// File extension
|
||||||
$fileExtension = pathinfo($_FILES['profilePictureInputFile']['name'], PATHINFO_EXTENSION);
|
$fileExtension = pathinfo($_FILES['profilePictureInputFile']['name'], PATHINFO_EXTENSION);
|
||||||
// Username who is uploading the image
|
|
||||||
$username = $login->username();
|
|
||||||
// Tmp filename
|
// Tmp filename
|
||||||
$tmpFilename = $username.'.'.$fileExtension;
|
$tmpFilename = $username.'.'.$fileExtension;
|
||||||
// Final filename
|
// Final filename
|
||||||
|
|
Loading…
Reference in New Issue