For my Catalyst project (FastCGI under Apache2), I would like to have an upload progress bar. The form is created with HTML::FormHandler and contains several text fields and a file upload input (it is not a pure file uploader).
So far, I tried 1) Catalyst::Plugin::UploadProgress and 2) jQuery Form Plugin - without success. Form submission and file upload still works, but with 1) no progress bar is visible and with 2) the progress bar stays at 0%.
I followed the docs as close as possible. What am I missing? Should these solutions work with Catalyst out of the box?
Attempt 1) Catalyst::Plugin::UploadProgress
<head>
<link href="/static/css/progress.css" rel="stylesheet" type="text/css" />
</head>
<form enctype="multipart/form-data" action="/run/start" method="post" onsubmit="return startEmbeddedProgressBar(this)">
<input type="text" name="name" />
<input type="date" name="date" />
<input type="file" name="file" />
<input type="submit" name="submit" />
</form>
<div id="progress"></div>
<script src="/static/js/progress.js" type="text/javascript"></script>
<script src="/static/js/progress.jmpl.js" type="text/javascript"></script>
Attempt 2) jQuery Form Plugin
<head>
<link href="/static/css/progress.css" rel="stylesheet" type="text/css" />
</head>
<form enctype="multipart/form-data" action="/run/start" method="post">
<input type="text" name="name" />
<input type="date" name="date" />
<input type="file" name="file" />
<input type="submit" name="submit" />
</form>
<div class="progress">
<div class="bar"></div >
<div class="percent">0%</div >
</div>
<div id="status"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>
(function() {
var bar = $('.bar');
var percent = $('.percent');
var status = $('#status');
$('form').ajaxForm({
beforeSend: function() {
status.empty();
var percentVal = '0%';
bar.width(percentVal)
percent.html(percentVal);
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
bar.width(percentVal)
percent.html(percentVal);
},
success: function() {
var percentVal = '100%';
bar.width(percentVal)
percent.html(percentVal);
},
complete: function(xhr) {
status.html(xhr.responseText);
}
});
})();
</script>