PDA

View Full Version : File Upload not working in IE.



mallempati
4 Mar 2010, 1:30 PM
I am using the below code to upload a file to server. It seems it is working in FireFox but not in IE. Can somebody please help me to solve this?

client side code:
----------------



uploadSecuritiesPanel = new Ext.FormPanel({
fileUpload: true,
width: '30%',
frame: true,
title: 'Load Securities from file',
height: 180,
bodyStyle: 'padding: 10px 10px 0 10px;',
border: false,
labelWidth: 20,
defaults: {
anchor: '95%',
allowBlank: false,
msgTarget: 'side'
},
items: [{
xtype: 'fileuploadfield',
id: 'form-file',
emptyText: 'Upload securities file',
fieldLabel: 'File',
name: 'file-path',
width: 100,
buttonText: '',
buttonCfg: {
iconCls: 'upload-icon'
}
}
],
buttons: [{
text: 'Load securities from file',
handler: function(){
if(uploadSecuritiesPanel.getForm().isValid()){
uploadSecuritiesPanel.getForm().submit({
url: 'CvgDispatcher?action=UPLOAD_SECURITIES',
waitMsg: 'Uploading your file...',
success: function(fp, o){
msg('Success', 'Processed file "'+o.result.result+'" on the server');
}
});
}
}
},{
text: 'Reset',
handler: function(){
uploadSecuritiesPanel.getForm().reset();
}
}]
});



server side code:
-----------------

boolean isMultipart = ServletFileUpload.isMultipartContent(request);
logger.info("is it multipart;" + isMultipart);
// Create a factory for disk-based file items

FileItemFactory factory = new DiskFileItemFactory();

// Create a new file upload handler

ServletFileUpload upload = new ServletFileUpload(factory);

// Parse the request

List<FileItem> fileItemsList = upload.parseRequest(request);
logger.info("fileItemsList: " + fileItemsList.size());
for (FileItem fileItem : fileItemsList) {
processed++;
}

I am getting processed = 1 in FireFox, but in IE it is 0.


Thanks,
Suresh

Animal
5 Mar 2010, 8:45 AM
I assume you are returning JSON according to http://www.extjs.com/deploy/dev/docs/?class=Ext.form.Action.Submit

Did you set the Content-Type header according to the instructions in the API docs?

Animal
5 Mar 2010, 8:59 AM
Oh, it's a problem on your server side. I thought you were posting an Ext question.

The class which handles uploads from IE must be able to handle a broken packet.

The filename contains the path. It shouldn't do that for a start. But also, the path contains single slashes!

Check out the packet with fidder.

Here's what I saw:



POST /fclasp61M/CorrespondenceMaint.do?AjaxFileUpload HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-silverlight, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, */*
Referer: http://10.0.1.14:8080/fclasp61M/AspCtrlIndex.jsp?cic=FCL&cin=FCL+Development+(FCL+61m)&clif=asp_lgo_fcl.gif&[email protected]&stct=delta&xfpn=2518&scheme=ext&asp_wt=1&asp_ss=1
Accept-Language: en-gb
Content-Type: multipart/form-data; boundary=---------------------------7d93ba21301d8
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
Host: 10.0.1.14:8080
Content-Length: 25053
Connection: Keep-Alive
Pragma: no-cache
Cookie: JSESSIONID=0912E813627945B56C99E6F51ABABA3B; ys-dontShowLanding=o%3Achecked%3Db%253A1

-----------------------------7d93ba21301d8
Content-Disposition: form-data; name="returnJson"

true
-----------------------------7d93ba21301d8
Content-Disposition: form-data; name="corrspmaster"

3RME0900012
-----------------------------7d93ba21301d8
Content-Disposition: form-data; name="corrsptmode"

3
-----------------------------7d93ba21301d8
Content-Disposition: form-data; name="corrspfile"; filename="\\Nigelw\Nigel's C\Documents and Settings\nigelw\My Documents\My Pictures\BDCA2004small.jpg"
Content-Type: image/pjpeg



So you see that the file name will end up being

"\NigelwNigel's CDocuments and SettingsnigelwMy DocumentsMy PicturesBDCA2004small.jpg" in most APIs which do not account for that.

mallempati
5 Mar 2010, 11:13 AM
Thank you for letting me know the root cause of the issue. Now I tried in IE8 and it is working.

Thanks
Suresh

nanduhc
27 May 2010, 11:58 AM
Thank you for letting me know the root cause of the issue. Now I tried in IE8 and it is working.

Thanks
Suresh

Hi Suresh, am having the same problem. Did this code start working for you when you tested using IE8 or did you have to modify your server side code.
Thanks
Nandu