bug fix profile picture

This commit is contained in:
Diego Najar 2018-10-29 18:21:42 +01:00
parent 859ca4ef52
commit ccdcba8699
2 changed files with 21 additions and 4 deletions

View File

@ -242,10 +242,16 @@ $(document).ready(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({
url: "<?php echo HTML_PATH_ADMIN_ROOT ?>ajax/profile-picture",
url: HTML_PATH_ADMIN_ROOT+"ajax/profile-picture",
type: "POST",
data: new FormData($("#jsprofilePictureForm")[0]),
data: formData,
cache: false,
contentType: false,
processData: false,

View File

@ -1,6 +1,19 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
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'])) {
exit (json_encode(array(
'status'=>1,
@ -10,8 +23,6 @@ if (!isset($_FILES['profilePictureInputFile'])) {
// File extension
$fileExtension = pathinfo($_FILES['profilePictureInputFile']['name'], PATHINFO_EXTENSION);
// Username who is uploading the image
$username = $login->username();
// Tmp filename
$tmpFilename = $username.'.'.$fileExtension;
// Final filename