File upload in extjs 4.2 without form.submit()

后端 未结 4 2188
闹比i
闹比i 2021-01-05 16:17

I\'m trying to upload a file (as of now of any extension) in extjs. I have a model and store. the file upload happens from a window and I dont have a form in the window. All

4条回答
  •  一个人的身影
    2021-01-05 16:45

    Yes, you can use Ajax and FormData API:

    var file = s.fileInputEl.dom.files[0],
         data = new FormData();
    data.append('file', file);
    Ext.Ajax.request({
       url: '/upload/files',
       rawData: data,
       headers: {'Content-Type':null}, //to use content type of FormData
       success: function(response){
       }
    });
    

    See my demo here

提交回复
热议问题