I want to implement simple file upload with progress
I like the services provides by jQuery-File-Upload
I tested the example provided with script
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>jQuery File Upload Example</title>
<style>
.bar {
height: 18px;
background-image: url('img/progressbar.gif');
}
</style>
</head>
<body>
<input type="text" name="textfield" /> title
<input id="fileupload" type="file" name="files[]" data-url="upload.php" >
<a href="#" id="upload" >Upload</a>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="js/vendor/jquery.ui.widget.js"></script>
<script src="js/jquery.iframe-transport.js"></script>
<script src="js/jquery.fileupload.js"></script>
<script>
$('#fileupload').fileupload({
dataType: 'json',
add: function (e, data) {
data.context = $('<p/>').text('Uploading...').appendTo(document.body);
data.submit();
},
done: function (e, data) {
data.context.text('Upload finished.');
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('#progress .bar').css(
'width',
progress + '%'
);
}
});
</script>
<div id="progress">
<div class="bar" style="width: 0%;"></div>
</div>
</body>
</html>
the code works perfectly when user select file, but I need the following settings
- Upload file when click on upload button.
- save information provided with the file in mysql db.
- upload a second picture along with main file.
- limit the items to only one file per upload.
- show upload status ( KB up - time remaining ).