PDA

View Full Version : FileUpload with custom header?



phuang3
21 Jul 2010, 8:06 PM
I am using Ext in a legacy Struts2 project. Struts2 has its own exception handling mechanism. (by forwarding to error pages) However, most of my request are Ajax calls by Ext.Ajax, so I defined a global custom header by calling "Ext.Ajax.defaultHeaders={'Powered-By':'Ext'};". In my project, a custom exception interceptor will check for this header, and any exception message is converted to JSON format, like "{success:false,Msg:'Server error!'}". Now, with "fileUpload:true" in FormPanel, setting customer headers with headers:{'Powered-By':'Ext'} in form.submit() method will not result in sending custom header. Here is my code:


form.submit({
url:SaleAction_saveForm.action,
param:{...},
headers:{'Powered-By':'Ext'},
success:function(){...},
failure:function(){...}
});


I know the file upload is done by dynamic iframe trick. Is it possible to add a custom header while doing file upload?

Animal
21 Jul 2010, 11:07 PM
No. You can't add headers when you submit HTML <form>s

phuang3
22 Jul 2010, 1:40 AM
Thanks, I've used a different way to solve this problem.

mehume20
17 Apr 2015, 1:03 PM
Thanks, I've used a different way to solve this problem.

so can some one share what is a solution?