Thursday, April 25, 2013

SWF File uploader issue fixation in codeigniter - SWF DEBUG: Event: uploadError : IO Error : File ID: SWFUpload_0_0. IO Error: Error #2038

Codeigniter - SWF file uploader issue fixation.

I was spent too much time on fixing a issue of SWF uploader and simply fixed it after a long time.

I was getting the error like

SWF DEBUG: Event: uploadError : IO Error : File ID: SWFUpload_0_0. IO Error: Error #2038

And I fixed it by just changing

upload_url: "http://abc.com/order/uploadFiles",

TO

upload_url : "http://abc.com/index.php/order/uploadFiles",

now the whole function will be:


$(function(){
$('#swfupload-control').swfupload({
upload_url: "http://abc.com/index.php/order/uploadFiles",
file_post_name: 'uploadfile',
file_size_limit : "1024",
file_types : "*.csv",
file_types_description : "Image files",
file_upload_limit : 1,
flash_url : "<?=base_url()?>assets/swfupload/swfupload.swf",
button_image_url : '<?=base_url()?>assets/swfupload/XPButtonUploadText_61x22.png',
button_width : 114,
button_height : 20,
button_placeholder : $('#button')[0],
debug: true
})
.bind('fileQueued', function(event, file){
var listitem='<li id="'+file.id+'" >'+
'File: <em>'+file.name+'</em> ('+Math.round(file.size/1024)+' KB) <span class="progressvalue" ></span>'+
'<div class="progressbar" ><div class="progress" ></div></div>'+
'<p class="status" >Pending</p>'+
'<span class="cancel" >&nbsp;</span>'+
'</li>';
$('#log').append(listitem);
$('li#'+file.id+' .cancel').bind('click', function(){
var swfu = $.swfupload.getInstance('#swfupload-control');
swfu.cancelUpload(file.id);
$('li#'+file.id).slideUp('fast');
});
// start the upload since it's queued
$(this).swfupload('startUpload');
})
.bind('fileQueueError', function(event, file, errorCode, message){
alert('Size of the file '+file.name+' is greater than limit');
})
.bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){
$('#queuestatus').text('Files Selected: '+numFilesSelected+' / Queued Files: '+numFilesQueued);
})
.bind('uploadStart', function(event, file){
$('#log li#'+file.id).find('p.status').text('Uploading...');
$('#log li#'+file.id).find('span.progressvalue').text('0%');
$('#log li#'+file.id).find('span.cancel').hide();
})
.bind('uploadProgress', function(event, file, bytesLoaded){
//Show Progress

var percentage=Math.round((bytesLoaded/file.size)*100);
$('#log li#'+file.id).find('div.progress').css('width', percentage+'%');
$('#log li#'+file.id).find('span.progressvalue').text(percentage+'%');
})
.bind('uploadSuccess', function(event, file, serverData){
var item=$('#log li#'+file.id);
item.find('div.progress').css('width', '100%');
item.find('span.progressvalue').text('100%');
var pathtofile='<a href="uploads/'+file.name+'" target="_blank" >view &raquo;</a>';
item.addClass('success').find('p.status').html('Done!!! | '+pathtofile);
})
.bind('uploadComplete', function(event, file){
// upload has completed, try the next one in the queue
$(this).swfupload('startUpload');
})

});


No comments:

Post a Comment