[trick] Update Foto Profil Ala Facebook Dengan Javascript

Lihat Gambar Di Bawah Ini :

fb


<script>
function uploadFile() {
var file = document.getElementById('file').files[0];
var formdata = new FormData();
formdata.append('foto', file);
var ajax = new XMLHttpRequest();
ajax.upload.addEventListener('progress', progressHandler, false);
ajax.open('POST', 'update_profile.php', true);
ajax.send(formdata);
}
function progressHandler(event){
var percent = (event.loaded / event.total) * 100;
document.getElementById('progressBar').value = Math.round(percent);
document.getElementById('status').innerHTML = Math.round(percent)+'% telah terupload';
document.getElementById('total').innerHTML = 'Telah terupload '+event.loaded+' bytes dari '+event.total;
}
</script>";

echo"<form enctype='multipart/form-data'>
<input type=file name='foto' id='file' onchange='uploadFile()'> <br>

</form>
<progress id='progressBar' value='0' max='100' style='width:210px;'></progress>
<center><b id='status'></b></center>
<center><a href='home.php?menu=admin'> Refresh </a></center>

tampilan

Leave a comment

1 Comment

  1. Keren sharing-nya

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: