Getting the uploading file name before upload with jQuery File Upload plugin

自闭症网瘾萝莉.ら 提交于 2019-12-01 05:45:52

Ok, here's the solution which works:

// Storing the file name in the queue
var fileName = "";

// On file add assigning the name of that file to the variable to pass to the web service
$('#fileupload').bind('fileuploadadd', function (e, data) {
  $.each(data.files, function (index, file) {
    fileName = file.name;
  });
});

// On file upload submit - assigning the file name value to the form data
$('#fileupload').bind('fileuploadsubmit', function (e, data) {
  data.formData = {"file" : fileName};
});
var filename = $('input[type=file]').val().split('\\').pop();

I have no idea of what kind of web service your site used, resume that is ashx, if that you can use

HttpPostedFile file = context.Request.Files["Filedata"];

to fetch the filename;

or use jquery

$("#yourid").uploadify({
.....
    'onSelect': function(e, queueId, fileObj)
    {
        alert( "FileName:" + fileObj.name);
    }
});

// jquery-file-upload

$('#fileupload').fileupload({
drop: function (e, data) {
    $.each(data.files, function (index, file) {
        alert('Dropped file: ' + file.name);
    });
},
change: function (e, data) {
    $.each(data.files, function (index, file) {
        alert('Selected file: ' + file.name);
    });
}

});

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!