2026, 새로운 도약을 시작합니다.

프로필 이미지 업로드 버튼을 눌렀을 때 올린 사진으로 프로필이 변경되게 하려면 어떻게 해야 할까요?

Copy










2023 MINI HOMEPAGE


































   TODAY 28 | TOTAL 234918

      BTeam의 잡동사니









로그인 / 회원가입























프로필 이미지 업로드



















저장



인사말 수정











Related Link







Home

Naver

Kosmo132












Updated news





 사진첩  아기하마

 게시판  티벳토끼의 잡동사니입니다

 게시판  둘러보고 가세요~

 사진첩  아빠가 왕도마뱀이면?







다이어리 0/25

    사진첩 0/25

게시판 0/25

     방명록 0/25








Miniroom















  홈

  다이어리

  사진첩

  캘린더













/*

 

// Thumbnail image preview

function readURL(input) {

if (input.files && input.files[0]) {

var reader = new FileReader();

reader.onload = function(e) {

$('#imgx').attr('src', e.target.result);

}

reader.readAsDataURL(input.files[0]);

}

}

$(function() {

$('#mfile').change(function() {

if ($(this).val().length > 0) {

readURL(this);

} else {

console.log("No image selected");

}

});

});

 

// Toggle edit mode for profile text

function toggleEditMode() {

const profileText = document.getElementById('profileText');

const editProfile = document.getElementById('editProfile');

const editProfileButton = document.getElementById('editProfileButton');

const profileTextarea = document.getElementById('profileTextarea');

 

if (editProfile.style.display === 'none') {

editProfile.style.display = 'block';

profileText.style.display = 'none';

editProfileButton.style.display = 'none';

profileTextarea.value = profileText.textContent;

} else {

editProfile.style.display = 'none';

profileText.style.display = 'block';

editProfileButton.style.display = 'block';

}

}

 

document.getElementById('saveProfileButton').addEventListener('click', function() {

const profileText = document.getElementById('profileText');

const profileTextarea = document.getElementById('profileTextarea');

 

profileText.textContent = profileTextarea.value;

toggleEditMode();

});

 

/*]]>*/





$(function() {

$('#updateProfileButton').click(function() {

const mini_pro_nick = $('#mini_pro_nick').val();

const formData = new FormData();

formData.append('mini_pro_nick', mini_pro_nick);

formData.append('mfile', $('#mfile')[0].files[0]);

 

$.ajax({

type: 'POST',

url: '/trip/mini/mproInsert',

data: formData,

processData: false,

contentType: false,

success: function(data) {

console.log('통신 성공: ' + data);

// You can perform any additional actions here after successful upload

},

error: function() {

console.log('통신 실패');

}

});

});

});







여기서 사진을 올리면 적용이 되어야 하는데 새로고침을 누르면 바로 사라지는데 어떻게 해야 할까요?

답변 1개

서버로 업데이트 하는부분을 추가 해줘야할듯 합니다.

if (editProfile.style.display === 'none') {
editProfile.style.display = 'block';
profileText.style.display = 'none';
editProfileButton.style.display = 'none';
profileTextarea.value = profileText.textContent;
} else {
editProfile.style.display = 'none';
profileText.style.display = 'block';
editProfileButton.style.display = 'block';


$.ajax({
    type: 'POST',
    url: '/updateProfile', 
    data: { profileText: profileTextarea.value }, 
    success: function(data) {
   },
    error: function() {
   }
});

}
}
로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고