View Full Version : Using filefield xtype

1 Feb 2013, 10:13 AM

I didnt receive any responses for my previous to inquiries (http://www.sencha.com/forum/showthread.php?255351 and http://www.sencha.com/forum/showthread.php?255186) so I'll rephrase and make my question more generic so perhaps more people can relate to my issue.

Has anyone used the filefield xtype before in their ExtJS applications? If so how are you using them, particularly how you are attempting to send the file to the server side for processing.


3 Feb 2013, 2:01 PM
Your question is very generic. From the API:

You are responsible for returning success from server.

echo '{"success": "true"}';


4 Feb 2013, 7:24 PM
I am definitely returning a success:true from the server. However I think my problem is that what I am trying to return to the user is another file (file in, file out). Therefore I am setting the content type in the header of the response to 'application/vnd.ms-excel' . Could this be the reason why my success:true is not being read?

4 Feb 2013, 8:38 PM
Are you sending the type back? example:

// Sending headers to force the user to download the file
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: inline;attachment;filename="'.$reports_array['report_name'].'.xls"');

echo "{success:true}";

On the client side, just call window.open

success: function(xhr) {
window.open('xls/' + employee_report_name + '.xls');


6 Feb 2013, 3:33 PM
It seems that I am sending the file contents itself in the response and flushing the responses' buffer. That flush seems to be the reason my success:true is not being sent back to the client.

My back end is Java/Spring so I'm doing something like

response.setHeader("Content-Disposition","attachment; filename=\"" + spreadsheetName +"\"");
// copy spreadhseet contents into response //
//..... later on...... //
Map<String, Object> modelMap = new HashMap<String, Object>();
modelMap.put("success", true);
ModelAndView modelView = new ModelAndView("jsonresponse", modelMap);

return modelView;

The issue is I dont know of another way of returning the file to the client. Is there another way of doing this so the file contents gets sent to the client AND my model map with success:true gets sent too?