Is it possible to upload a (pdf) file using HTML5 + Ajax + jQuery + C# ?
I need to upload a file w/o reloading the page.
As I'm not a web developer, please 'keep it simple' answering the question.:)
Is it possible to upload a (pdf) file using HTML5 + Ajax + jQuery + C# ?
I need to upload a file w/o reloading the page.
As I'm not a web developer, please 'keep it simple' answering the question.:)
With jquery.form plugin, it's very simple to do what you want:
HTML:
<form id="form" action="upload_page.php" method="post" enctype="multipart/form-data">
<input type="file" size="60" name="file">
<input type="submit" value="Upload file">
</form>
<div id="progress">
<div id="bar"></div>
<div id="percent">0%</div >
</div>
JS:
$(document).ready(function () {
var options = {
beforeSend: function () {
$("#progress").show();
//clear everything
$("#bar").width('0%');
$("#message").html("");
$("#percent").html("0%");
},
uploadProgress: function (event, position, total, percentComplete) {
$("#bar").width(percentComplete + '%');
$("#percent").html(percentComplete + '%');
},
success: function () {
$("#bar").width('100%');
$("#percent").html('100%');
},
complete: function (response) {
$("#message").html("<font color='green'>" + response.responseText + "</font>");
},
error: function () {
$("#message").html("<font color='red'> ERROR: unable to upload files</font>");
}
};
$("#form").ajaxForm(options);
});
This will also give you a nice progress bar which you can style however you want.
We have a ASP.NET uploader written in c#+ajax in our GPL package which you can find here: