I’m trying to create an upload script and got that. Its a profile image upload script so everytime a user chnages the profile image the name will still be the same: userid.jpg.
Is there a way to refresh my image if success…
if (success == 1){
result = '<span class="msg">Image uploaded...<\\/span><br/><br/>';
// Something here to tell my image to refresh? //
}
I assume your using PHP to manage the upload so what you need to do is use something like a JSON array when returning the data back to the JS function and set the new image path within that. For example…
Javascript
$.ajax({
success: function(data) {
if (data.status) {
result = '<span class="msg">Image uploaded...<\\/span><br/><br/>';
if (data['image'].length > 0) {
$('#img_id').attr('src', data.image);
}
} else {
alert('Error!');
}
}
});