[trick] Update Foto Profil Ala Facebook Dengan Javascript

Lihat Gambar Di Bawah Ini :


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);
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;

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

<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>


Leave a comment

1 Comment

  1. Keren sharing-nya


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: