I am using youtube api for upload videos from my webpage.
This is my html form:
<form method="post" id="video_form" enctype="multipart/form-data" action="http://uploads.gdata.youtube.com/action/FormDataUpload/key=http://localhost:3000/en/id=4fc3af871d41c808f3000249" accept-charset="UTF-8"><div style="margin:0;padding:0;display:inline"><input type="hidden" value="✓" name="utf8"><input type="hidden" value="key=" name="authenticity_token"></div>
<label for="Select_a_video">Select a video</label>
<input type="file" name="yt_video_id" id="yt_video_id">
<div class="actions">
<input type="submit" value="Upload video" name="commit" id="submit_video_button" data-disable-with="Upload video" class="btn-large btn-primary">
</div>
</form>
I use twitter bootstrap for design and I have this progress bar:
$(document).ready(function(){
var progress = setInterval(function() {
var $bar = $('.bar');
if ($bar.width()==400) {
clearInterval(progress);
$('.progress').removeClass('active');
} else {
$bar.width($bar.width()+40);
}
$bar.text($bar.width()/4 + "%");
}, 800);
});
you can see example in http://jsfiddle.net/xXM2z/68/
My problem is that the progress bar (progress) is not synchronized with the bytes or megabytes that has sent the file.
I want the progress bar is synchronized with the bytes or megabytes that has sent the file and it displays correctly progress…
How can I do it?
Thank you very much
AFAIK, you can’t, unless you use AJAX/XHR to upload the file instead. If you leave it up to the browser, you will only know when the whole file has been uploaded.
Here’s an XHR example:
http://hacks.mozilla.org/2009/06/xhr-progress-and-richer-file-uploading-feedback/
However, I don’t know whether the YouTube API supports this or not.