In our project we are using plupload to upload a single excel file. This is working in all the browsers except IE9. On click of the upload link the file dialog box is displayed but nothing happens when tried to open the excel. Below is the code for reference and any help to solve this will be much appreciated. Thanks in advance!
function initUploader(btnId, fileType, onSuccess) {
if (typeof fileType == "undefined") fileType = "image";
var arrFilters = new Array();
var url = 'user/attachmentUpload';
switch (fileType) {
case "image":
arrFilters = [{title : "Image files", extensions : "jpg,jpeg,gif,png"}];
url = 'assets/imgupload';
break;
case "xls":
arrFilters = [{title : "Spreadsheet files", extensions : "xls,xlsx"}];
url = 'user/attachmentUpload';
break;
case "media":
arrFilters = [{
title : "Media files",
extensions : "mpeg4,mob,3gpp,avi,wmv,mp3,m4a,ogg,wav"
}];
break;
case "document":
arrFilters = [{
title : "Text files",
extensions : "doc,docx"
},{
title : "PDF files",
extensions : "pdf"
}];
break;
default:
arrFilters = [
{
title : "Image files",
extensions : "jpg,jpeg,gif,png"
},
{
title : "Zip files",
extensions : "zip"
},
{
title : "Media files",
extensions : "mpeg4,mob,3gpp,avi,wmv,mp3,m4a,ogg,wav"
},
{
title : "Spreadsheet files",
extensions : "xls,xlsx"
},
{
title : "Text files",
extensions : "doc,docx"
},
{
title : "PDF files",
extensions : "pdf"
}
];
break;
}
var uploader = new plupload.Uploader({
runtimes : 'gears,html5,html4,flash,silverlight,browserplus',
browse_button : btnId,
//container : 'container',
max_file_size : '10mb',
url : url,
flash_swf_url : 'assets/js/vendor/plupload/plupload.flash.swf',
silverlight_xap_url : 'assets/js/vendor/plupload/plupload.silverlight.xap',
multiple_queues : false,
filters : arrFilters,
resize : {width : 320, height : 240, quality : 90}
});
$('#'+btnId).change(function(){
uploader.start();
});
uploader.refresh();
uploader.init();
uploader.bind('FilesAdded', function(up, files) {
up.refresh(); // Reposition Flash/Silverlight
Utility.showProcessingBar();
uploader.start();
});
uploader.bind('Error', function(up, err) {
alert("Error: " + err.code + ", Message: " + err.message + (err.file ? ", File: " + err.file.name : ""));
up.refresh(); // Reposition Flash/Silverlight
});
uploader.bind('FileUploaded', function(up, file, response) {
var obj = eval('(' + response.response + ')');
//alert('Files uploaded');
if (typeof onSuccess == "function")
onSuccess(obj.fileName);
});
}
For max compatibility you should rearrange the plugins priority list.
REPLACE THAT WITH
Make sure the flash file exist and the path is relative to the location of your js file.
For everyone who has the same problem as me:
I had the following HTML code:
The class
container
was created as dialog:As we know that the
div
is initially hidden because ofdisplay: none
(of course, you can set upautoOpen:false
as a new option in the dialog object), we can remove the style.In IE8 (probably in earlier and later version) the uploader cannot be instantiated properly if the
div
is hidden. (Returns the above error)In Chrome and Firefox (I did't test this issue in Opera), it works fine.
So, my advice is to avoid hidden blocks (even if you wish to create a modal dialog).
I removed the
display:none
style anddialog
object from thatdiv
and now it works very good in IE8.Why? I don't know why in IE, the instance of object is not created at the start-up of the page, though in Firefox and Chrome, the instance was created normally.
I am working with this jquery.
You can try this out as I am working with this in ie7+ and all browser fro my file uploads.
Here is the file code I am newbie on how to upload js file at here.
Example can be found from my fiddle.
Have a happy coding :)
live demo use working in ie7 http://vasplus.info/demos/upload_without_page_refresh/index.php