PDA

View Full Version : SWFUpload supports Flash version 10



santoshrestha
9 Oct 2009, 1:04 PM
Hello,

Here is the SWFuploadPanel that supports Flash version 10. I have enhanced it with row level progressbar.

http://showcase.rumsan.com/swfupload/

Thanks.

jay@moduscreate.com
14 Oct 2009, 5:37 AM
Awesome dude.

mschwartz
14 Oct 2009, 6:51 AM
Works with ext 3.0.0?

jay@moduscreate.com
14 Oct 2009, 6:58 AM
His demo page is using 3.0 according to Ext.version

Bulle Bas
14 Oct 2009, 11:24 AM
Well done!

Is your work also MIT-licensed (http://www.opensource.org/licenses/mit-license.php)? I hate to find myself asking this question about legal , being an it-man but anyways.

santoshrestha
14 Oct 2009, 10:04 PM
Thanks guys. Yes it is MIT-Licensed. Feel free to use or modify.

aw1zard2
10 Nov 2009, 7:58 AM
Excellent work on this.

I have hit small issue and I think it's more how IE8 handles security. But when I click the addfiles button no file browser is shown.

I got it to work in IE8 by forcing IE7 compatibility.

Is anyone else have problems with this in IE8?

Thanks.

:)

Mad_Clog
10 Nov 2009, 9:15 AM
Is anyone else have problems with this in IE8?
It's working fine in IE8 here (tested all modes).
Only thing i noticed was a small css bug in IE8 compt. and IE7 mode (progress bar would expand to much)

aw1zard2
10 Nov 2009, 10:43 AM
I also noticed the IE7 progress bar bug.
But I have it inside a card layout wizard and its on the first card. Everything works in the other browsers but in IE8 I have to set the compat to IE7 for it to display the file browser dialog.

I'll make a simple case of it tonight and see if it happens might be something else conflicting with it.

Thanks for the reply.

haldrix
12 Nov 2009, 10:17 PM
I have some problem using this f*** good ;) component in a tabpanel.
When i click on "upload files", then i switch to another panel in the tabpanel and leave the upload process working in background. If i go back to the swfupload panel, all the progress bar freeze. I try to change panel visibility to
hideMode: 'offsets'
...noway !

Any Idea ?

Salamander
16 Dec 2009, 12:33 AM
=D> Well done! This saved me a lot of trouble! Thanks for sharing!

meisong
20 Dec 2009, 12:30 AM
好好好...=D>

jerrel
17 Jan 2010, 4:56 AM
Dear santoshrestha,

Nice work, i've been looking for a solution like this one.
I checked out your example, and noticed that the progress indicator jumps to 100% at once.
I noticed that the bar gives the same result for both a 10 Kb file and a 1.97 MB file.
Is the bar an animation are is it a bug?
It would be very nice, if the progress bar and the status column where working sync.


Looking foward to you reply.

regards
J

aw1zard2
17 Jan 2010, 9:20 AM
Just letting you know of a new bug.

SWFUpload works fine with 3.1.0 but breaks with 3.1.1-beta.

Inside the SWFUploadPanel.js line 339.

=)

jerrel
17 Jan 2010, 11:09 AM
He Guys,
I set up the swfupload, created the html as below, but the Add files icon does not fire browse window
Any idea what im doing wrong here ?



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"><title>
Rumsan
</title>
<script>
session = "jthata45uowqmyrv12roti55";
</script>
<script src="adapter/ext/ext-base.js" type="text/javascript"></script>
<link href="resources/css/ext-all.css" rel="stylesheet" type="text/css" />
<script src="ext-all.js" type="text/javascript"></script>
<link href="my_jsscripts/SWFUpload/SwfUploadPanel.css" rel="stylesheet" type="text/css" />
<script src="my_jsscripts/SWFUpload/swfupload.js" type="text/javascript"></script>
<script src="my_jsscripts/SWFUpload/SwfUploadPanel.js" type="text/javascript"></script>
<script src="my_jsscripts/SWFUpload/init.js" type="text/javascript"></script>

</head>
<body>
<form name="form1" method="post" action="Default.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEyNTM4MjMyMTZkZNKKV8mgMo+nYYH6F4Ytyor0oUPp" />
</div>
<div id="placeholder"></div>
</form>

</body>
</html>

jerrel
17 Jan 2010, 6:20 PM
He Guys,

I got the SWFupload working.
What i did was move my swfupload.html as seen in my previous post to the folder where the all other swf*** js files reside.

i dont fully understand why this works, but i think that somewhere in one of the scripts there is a call to a file with a relative path ./ (based on where the html file resides)

Any help to resolve this is really appreciated,

@aw1zard2

Did you get to resolve the IE8.0 progressbaar bug ?
Im also struggeling with this issue.

aw1zard2
20 Jan 2010, 2:05 PM
I haven't had time to look at it. I've been checking code in my project against Ext 3.1.1.

After I get a few last fixes working I will take a look at it. I also was thinking of doing something similar as an component and sharing it.

:)

aw1zard2
5 Feb 2010, 9:21 AM
Ext JS 3.1.1_rc fixed the problem I was having with the button not being referenced correctly. You might want to check against that and see if your issues still exist.

:)

dawesi
9 Feb 2010, 5:47 PM
swfupload finally works through our proxy in firefox without locking up!!

ie8 also works through the firewall... sweeeeeeeeeeeeeeet. Finally!

Thank you!

mschwartz
10 Feb 2010, 11:20 AM
Semi OT

http://blog.moxiecode.com/2010/02/03/plupload-released/

An Ext extension for this would rock!

smartlit
6 Apr 2010, 7:54 AM
Congratulations for this excellent component!!

I also noticed the progress-bar bug under IE7. Did someone solve this issue?
Thank you!! :)

Paul

Muhlegg
14 Apr 2010, 12:32 AM
He Guys,

I got the SWFupload working.
What i did was move my swfupload.html as seen in my previous post to the folder where the all other swf*** js files reside.

i dont fully understand why this works, but i think that somewhere in one of the scripts there is a call to a file with a relative path ./ (based on where the html file resides)

Any help to resolve this is really appreciated,

@aw1zard2

Did you get to resolve the IE8.0 progressbaar bug ?
Im also struggeling with this issue.

Make sure you set the flash_url config as well. The default flash_url is "swfupload.swf".

wurstkuchen
11 Jun 2010, 4:37 AM
Hey,

nice work! Your demo looks great!

Iam trying to get it run for my own.
But I always get problems with the following line:



this.getBottomToolbar() is undefinedchrome://firebug/content/blank.gif this.progress_bar.setWidth(this.getBottomToolbar().el.getWidth() - 5); Some idea what it could be?

Iam using EXT 3.2.1

Thank you!

aw1zard2
11 Jun 2010, 6:26 AM
Hey,

nice work! Your demo looks great!

Iam trying to get it run for my own.
But I always get problems with the following line:



this.getBottomToolbar() is undefinedchrome://firebug/content/blank.gif this.progress_bar.setWidth(this.getBottomToolbar().el.getWidth() - 5); Some idea what it could be?

Iam using EXT 3.2.1

Thank you!

I have this working with no problems on Ext 3.2.1 and Firefox 3.6.3. Let me check the other browsers.

Works with:
Firefox 3.6.3 for Windows
Safari 4 and 5 for Windows
Opera 10 for Windows

I can't check chrome while at work so give me a few and I will see if I can get the IT group to fix it so I can. LOL

dbassett74
5 Jul 2010, 8:46 AM
Is there any way that this component could be updated to revert to standard (one at a time) file uploading if the end user doesn't have Flash installed/enabled? I have seen commercial components pull this off so I'm sure its possible.

omerfarooq123
5 Jul 2010, 1:20 PM
any help about installation ??

tobiu
14 Jul 2010, 7:24 AM
hello,

i really like this UX, but it is not working in IE8,
neither in normal mode, nor in compat mode.

if i open the demo under:
http://showcase.rumsan.com/swfupload/

i get the screen i have added here.



var em = this.addBtn.el.child('em');

em.createChild({
tag: 'div',
id: suoID
});


is visibly shown over the button and nothing happens onClick.


kind regards,
tobiu

aw1zard2
14 Jul 2010, 7:42 AM
I have noticed you can't have this component too nested otherwise the dialog box didn't show also the click area sometimes doesn't fit right over the button area.

I would double check both.

tobiu
14 Jul 2010, 8:18 AM
important update to my topic: it DOES run in ie8 with windows XP, it does not run in ie8 with windows 7 -> neither the 32bit nor the 64bit version!


kind regards,
tobiu

tobiu
15 Jul 2010, 1:49 AM
please let us know, if you are going to take a look into the ie8 issues or if we have to do it by ourselves.

i found another small bug:

line 292:


//this.bbar = [this.progress_bar];


the progressbar -> the whole bottomToolbar is commented out.

line 325:


(function(){
this.on('resize', this.resizeProgressBar, this);
}).defer(100, this);


so, if you resize the panel, firebug throws an error because there is no bbar.

the fix is quite simple:


resizeProgressBar: function() {
if(!this.getBottomToolbar())return;
this.progress_bar.setWidth(this.getBottomToolbar().el.getWidth() - 5);
Ext.fly(this.progress_bar.el.dom.firstChild.firstChild).applyStyles("height: 18px");
}


if the idea is, to make it optionally included (then there should be a config to use it or not). if the bbar is out of date, all belonging code should be removed.


kind regards,
tobiu

tobiu
15 Jul 2010, 2:04 AM
next report and fix =)

line 266:


render: function(){
this.initButton();
}


has to be changed to


render: function(){
this.initButton.defer(100, this);
}


the problem was, that the flash-input field had not the right width, it was 18px to small -> 61px instead of 79.
i think this was caused, by the rendering of the button-icon, which was executed after the method initButton.

without this fix, nothing will happen if you click on the right side of the btn.


kind regards,
tobiu

tobiu
15 Jul 2010, 5:22 AM
ie8 issue "fixed".

ok, i could bite into the table. 3 times at least...
on this office-computer, ie blocked the active-x control of flash 10.
on my screen was a small box, almost looking like a line above the icon.
i ran through the dom and css, managed to span it wider and it turned out to be a white box with a red cross -> the icon for no flash available....... *narf*

so, here is the current version i use including the fixes i posted before:



// Create user extension namespace
Ext.ns('Ext.ux');

/**
* @class Ext.ux.SwfUploadPanel
* @extends Ext.grid.GridPanel

* Makes a Panel to provide the ability to upload multiple files using the SwfUpload flash script.
*
* @author Stephan Wentz
* @author Michael Giddens (Original author)
* @website http://www.brainbits.net
* @created 2008-02-26
* @version 0.5
*
* known_issues
* - Progress bar used hardcoded width. Not sure how to make 100% in bbar
* - Panel requires width / height to be set. Not sure why it will not fit
* - when panel is nested sometimes the column model is not always shown to fit until a file is added. Render order issue.
*
* @constructor
* @param {Object} config The config object
*/
Ext.ux.SwfUploadPanel = Ext.extend(Ext.grid.GridPanel, {

/**
* @cfg {Object} strings
* All strings used by Ext.ux.SwfUploadPanel
*/
strings: {
text_add: 'Add File(s)',
text_upload: 'Upload File(s)',
text_cancel: 'Cancel Upload',
text_clear: 'Clear Queue',
text_progressbar: 'Progress Bar',
text_remove: 'Remove File',
text_remove_sure: 'Are you sure you wish to remove this file from queue?',
text_error: 'Error',
text_uploading: 'Uploading file: {0} ({1} of {2})',
header_filename: 'Filename',
header_size: 'Size',
header_status: 'Status',
status: {
0: 'Queued',
1: 'Uploading...',
2: 'Completed',
3: 'Error',
4: 'Cancelled'
},
error_queue_exceeded: 'The selected file(s) exceed(s) the maximum number of {0} queued files.',
error_queue_slots_0: 'There is no slot left',
error_queue_slots_1: 'There is only one slot left',
error_queue_slots_2: 'There are only {0} slots left',
error_size_exceeded: 'The selected files size exceeds the allowed limit of 1 MB.',
error_zero_byte_file: 'Zero byte file selected.',
error_invalid_filetype: 'Invalid filetype selected.',
error_file_not_found: 'File not found 404.',
error_security_error: 'Security Error. Not allowed to post to different url.'
},

/**
* @cfg {Boolean} single_select
* True to allow multiple file selections, false for single file selection.
* Please note that this doesn't affect the number of allowed files in the queue.
* Use the {@link #file_queue_limit} parameter to change the allowed number of files in the queue.
*/
single_select: false,
/**
* @cfg {Boolean} confirm_delete
* Show a confirmation box on deletion of queued files.
*/
confirm_delete: true,
/**
* @cfg {String} file_types
* Allowed file types for the File Selection Dialog. Use semi-colon as a seperator for multiple file-types.
*/
file_types: "*.*", // Default allow all file types
/**
* @cfg {String} file_types
* A text description that is displayed to the user in the File Browser dialog.
*/
file_types_description: "All Files", //
/**
* @cfg {String} file_size_limit
* The file_size_limit setting defines the maximum allowed size of a file to be uploaded.
* This setting accepts a value and unit. Valid units are B, KB, MB and GB. If the unit is omitted default is KB.
* A value of 0 (zero) is interpretted as unlimited.
*/
file_size_limit: "1MB", // Default size limit 100MB
/**
* @cfg {String} file_upload_limit
* Defines the number of files allowed to be uploaded by SWFUpload.
* This setting also sets the upper bound of the {@link #file_queue_limit} setting.
* The value of 0 (zero) is interpretted as unlimited.
*/
file_upload_limit: "0", // Default no upload limit
/**
* @cfg {String} file_queue_limit
* Defines the number of unprocessed files allowed to be simultaneously queued.
* The value of 0 (zero) is interpretted as unlimited.
*/
file_queue_limit: "0", // Default no queue limit
/**
* @cfg {String} file_post_name
* The file_post_name allows you to set the value name used to post the file.
*/
file_post_name: "Filedata", // Default name
/**
* @cfg {String} flash_url
* The full, absolute, or relative URL to the Flash Control swf file.
*/
flash_url: "swfupload.swf", // Default url, relative to the page url
/**
* @cfg {Boolean} debug
* A boolean value that defines whether the debug event handler should be fired.
*/
debug: false,

// standard grid parameters
autoExpandColumn: 'name',
enableColumnResize: false,
enableColumnMove: false,

// private
upload_cancelled: false,

// private
initComponent: function() {

this.addEvents(
/**
* @event swfUploadLoaded
* Fires after the Flash object has been loaded
* @param {Ext.grid.GridPanel} grid This grid
*/
'swfUploadLoaded',
/**
* @event swfUploadLoaded
* Fires after a file has been qeueud
* @param {Ext.grid.GridPanel} grid This grid
* @param {Object} file The file object that produced the error
*/
'fileQueued',
/**
* @event startUpload
* Fires before the upload starts
* @param {Ext.grid.GridPanel} grid This grid
*/
'startUpload',
/**
* @event fileUploadError
* Fires after an upload has been stopped or cancelled
* @param {Ext.grid.GridPanel} grid This grid
* @param {Object} file The file object that produced the error
* @param {String} code The error code
* @param {String} message Supplemental error message
*/
'fileUploadError',
/**
* @event fileUploadSuccess
* Fires after an upload has been successfully uploaded
* @param {Ext.grid.GridPanel} grid This grid
* @param {Object} file The file object that has been uploaded
* @param {Object} data The response data of the upload request
*/
'fileUploadSuccess',
/**
* @event fileUploadComplete
* Fires after the upload cycle for one file finished
* @param {Ext.grid.GridPanel} grid This grid
* @param {Object} file The file object that has been uploaded
*/
'fileUploadComplete',
/**
* @event fileUploadComplete
* Fires after the upload cycle for all files in the queue finished
* @param {Ext.grid.GridPanel} grid This grid
*/
'allUploadsComplete',
/**
* @event fileUploadComplete
* Fires after one or more files have been removed from the queue
* @param {Ext.grid.GridPanel} grid This grid
*/
'removeFiles',
/**
* @event fileUploadComplete
* Fires after all files have been removed from the queue
* @param {Ext.grid.GridPanel} grid This grid
*/
'removeAllFiles'
);

this.rec = Ext.data.Record.create([
{name: 'name'},
{name: 'size'},
{name: 'id'},
{name: 'type'},
{name: 'creationdate', type: 'date', dateFormat: 'm/d/Y'},
{name: 'status'}
]);

this.store = new Ext.data.Store({
reader: new Ext.data.JsonReader({
id: 'id'
}, this.rec)
});

this.columns = [{
id:'name',
header: this.strings.header_filename,
dataIndex: 'name'
},{
id:'size',
header: this.strings.header_size,
width: 80,
dataIndex: 'size',
renderer: this.formatBytes
},{
id:'status',
header: this.strings.header_status,
width: 100,
dataIndex: 'status',
renderer: this.formatStatus.createDelegate(this)
},{
id:'progress',
header: 'Progess',
width: 150,
renderer: this.formatProgressBar
}

];

this.sm = new Ext.grid.RowSelectionModel({
singleSelect: this.single_select
});


this.progress_bar = new Ext.ProgressBar({
text: this.strings.text_progressbar,
// added by mh
listeners: {
render: function(){
this.resizeProgressBar();
},
scope: this
}
// end added
// width: this.width - 7
});

this.tbar = [{
text: this.strings.text_add,
iconCls: 'SwfUploadPanel_iconAdd',
xhandler: function() {
if (this.single_select) {
this.suo.selectFile();
}
else {
this.suo.selectFiles();
}
},
xscope: this,
// added by mh
listeners: {
render: function(){
this.initButton.defer(100, this);
},
scope: this
}
// end added
}, '->', {
text: this.strings.text_cancel,
iconCls: 'SwfUploadPanel_iconCancel',
handler: this.stopUpload,
scope: this,
hidden: true
}, {
text: this.strings.text_upload,
iconCls: 'SwfUploadPanel_iconUpload',
handler: this.startUpload,
scope: this,
hidden: true
}, {
text: this.strings.text_clear,
iconCls: 'SwfUploadPanel_iconDelete',
handler: this.removeAllFiles,
scope: this,
hidden: false
}];

//this.bbar = [this.progress_bar];

this.addListener({
keypress: {
fn: function(e) {
if (this.confirm_delete) {
if(e.getKey() == e.DELETE) {
Ext.MessageBox.confirm(this.strings.text_remove,this.strings.text_remove_sure, function(e) {
if (e == 'yes') {
this.removeFiles();
}
}, this);
}
} else {
this.removeFiles(this);
}
},
scope: this
},

// Prevent the default right click to show up in the grid.
contextmenu: function(e) {
e.stopEvent();
},

// modified by mh
render: function(){
this.addBtn = this.getTopToolbar().items.items[0];
this.cancelBtn = this.getTopToolbar().items.items[2];
this.uploadBtn = this.getTopToolbar().items.items[3];
this.clearBtn = this.getTopToolbar().items.items[4];

// defer to avoid resize on render
(function(){
this.on('resize', this.resizeProgressBar, this);
}).defer(100, this);
}
// end modified
});

Ext.ux.SwfUploadPanel.superclass.initComponent.call(this);
},

// modified by mh - refactor to separate method
initButton: function() {
var suoID = Ext.id();

var em = this.addBtn.el.child('em');
em.setStyle({
position: 'relative',
display: 'block'
});
var ch = em.createChild({
tag: 'div',
id: suoID
});

this.suo = new SWFUpload({
button_placeholder_id: suoID,
button_width: em.getWidth(),
button_height: em.getHeight(),
button_cursor: SWFUpload.CURSOR.HAND,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,

upload_url: this.upload_url,
post_params: this.post_params,
file_post_name: this.file_post_name,
file_size_limit: this.file_size_limit,
file_queue_limit: this.file_queue_limit,
file_types: this.file_types,
file_types_description: this.file_types_description,
file_upload_limit: this.file_upload_limit,
flash_url: this.flash_url,

// Event Handler Settings
swfupload_loaded_handler: this.swfUploadLoaded.createDelegate(this),

file_dialog_start_handler: this.fileDialogStart.createDelegate(this),
file_queued_handler: this.fileQueue.createDelegate(this),
file_queue_error_handler: this.fileQueueError.createDelegate(this),
file_dialog_complete_handler: this.fileDialogComplete.createDelegate(this),

upload_start_handler: this.uploadStart.createDelegate(this),
upload_progress_handler: this.uploadProgress.createDelegate(this),
upload_error_handler: this.uploadError.createDelegate(this),
upload_success_handler: this.uploadSuccess.createDelegate(this),
upload_complete_handler: this.uploadComplete.createDelegate(this),

debug: this.debug,
debug_handler: this.debug ? this.debugHandler : Ext.emptyFn
});

Ext.get(this.suo.movieName).setStyle({
position: 'absolute',
top: 0,
left: 0
});
},

formatProgressBar : function(_v, cellmeta, record){
switch(record.data.fileState){
case SWFUpload.FILE_STATUS.COMPLETE:
if(Ext.isIE){
returnValue =
'<div class="x-progress-wrap" style="height: 18px">' +
'<div class="x-progress-inner">' +
'<div style="width: 100%;" class="x-progress-bar x-progress-text">' + '100 %'
'</div>' +
'</div>' +
'</div>';
}else{
returnValue =
'<div class="x-progress-wrap" style="height: 18px">' +
'<div class="x-progress-inner">' +
'<div id="progressBar_' + record.data.id + '" style="width: 100%;" class="x-progress-bar">' +
'</div>' +
'<div id="progressText_' + record.data.id + '" style="width: 100%;" class="x-progress-text x-progress-text-back" />100 %</div>'
'</div>' +
'</div>';
}
break;
default :
returnValue =
'<div class="x-progress-wrap" style="height: 18px">' +
'<div class="x-progress-inner">' +
'<div id="progressBar_' + record.data.id + '" style="width: 0%;" class="x-progress-bar">' +
'</div>' +
'<div id="progressText_' + record.data.id + '" style="width: 100%;" class="x-progress-text x-progress-text-back" />0 %</div>'
'</div>' +
'</div>';
break;
}
return returnValue;
},

// private
resizeProgressBar: function() {
if(!this.getBottomToolbar())return;
this.progress_bar.setWidth(this.getBottomToolbar().el.getWidth() - 5);
Ext.fly(this.progress_bar.el.dom.firstChild.firstChild).applyStyles("height: 18px");
},

/**
* SWFUpload debug handler
* @param {Object} line
*/
debugHandler: function(line) {
console.log(line);
},

/**
* Formats file status
* @param {Integer} status
* @return {String}
*/
formatStatus: function(status) {
return this.strings.status[status];
},

/**
* Formats raw bytes into kB/mB/GB/TB
* @param {Integer} bytes
* @return {String}
*/
formatBytes: function(size) {
if (!size) {
size = 0;
}
var suffix = ["B", "KB", "MB", "GB"];
var result = size;
size = parseInt(size, 10);
result = size + " " + suffix[0];
var loop = 0;
while (size / 1024 > 1) {
size = size / 1024;
loop++;
}
result = Math.round(size) + " " + suffix[loop];

return result;

if(isNaN(bytes)) {
return ('');
}

var unit, val;

if(bytes < 999) {
unit = 'B';
val = (!bytes && this.progressRequestCount >= 1) ? '~' : bytes;
} else if(bytes < 999999) {
unit = 'kB';
val = Math.round(bytes/1000);
} else if(bytes < 999999999) {
unit = 'MB';
val = Math.round(bytes/100000) / 10;
} else if(bytes < 999999999999) {
unit = 'GB';
val = Math.round(bytes/100000000) / 10;
} else {
unit = 'TB';
val = Math.round(bytes/100000000000) / 10;
}

return (val + ' ' + unit);
},

/**
* SWFUpload swfUploadLoaded event
*/
swfUploadLoaded: function() {
if(this.debug) console.info('SWFUPLOAD LOADED');

this.fireEvent('swfUploadLoaded', this);
},

/**
* SWFUpload fileDialogStart event
*/
fileDialogStart: function() {
if(this.debug) console.info('FILE DIALOG START');

this.fireEvent('fileDialogStart', this);
},

/**
* Add file to store / grid
* SWFUpload fileQueue event
* @param {Object} file
*/
fileQueue: function(file) {
if(this.debug) console.info('FILE QUEUE');
file.status = 0;
r = new this.rec(file);
r.id = file.id;
this.store.add(r);

this.fireEvent('fileQueued', this, file);
},

/**
* Error when file queue error occurs
* SWFUpload fileQueueError event
* @param {Object} file
* @param {Integer} code
* @param {string} message
*/
fileQueueError: function(file, code, message) {
if(this.debug) console.info('FILE QUEUE ERROR');

switch (code) {
case -100:
var slots;
switch(message) {
case '0':
slots = this.strings.error_queue_slots_0;
break;
case '1':
slots = this.strings.error_queue_slots_1;
break;
default:
slots = String.format(this.strings.error_queue_slots_2, message);
}
Ext.MessageBox.alert(this.strings.text_error, String.format(this.strings.error_queue_exceeded + ' ' + slots, this.file_queue_limit));
break;

case -110:
Ext.MessageBox.alert(this.strings.text_error, String.format(this.strings.error_size_exceeded, this.formatBytes(this.file_size_limit * 1024)));
break;

case -120:
Ext.MessageBox.alert(this.strings.text_error, this.strings.error_zero_byte_file);
break;

case -130:
Ext.MessageBox.alert(this.strings.text_error, this.strings.error_invalid_filetype);
break;
}

this.fireEvent('fileQueueError', this, file, code/*, error*/);
},

/**
* SWFUpload fileDialogComplete event
* @param {Integer} file_count
*/
fileDialogComplete: function(file_count) {
if(this.debug) console.info('FILE DIALOG COMPLETE');

if (file_count > 0) {
this.uploadBtn.show();
}

this.addBtn.show();
this.clearBtn.show();

this.fireEvent('fileDialogComplete', this, file_count);
},

/**
* SWFUpload uploadStart event
* @param {Object} file
*/
uploadStart: function(file) {
if(this.debug) console.info('UPLOAD START');
this.fireEvent('uploadStart', this, file);

return true;
},

/**
* SWFUpload uploadProgress event
* @param {Object} file
* @param {Integer} bytes_completed
* @param {Integer} bytes_total
*/
progressCount : 0,
uploadProgress: function(file, bytes_completed, bytes_total) {
//if(this.debug)
var percent = Math.ceil((bytes_completed / bytes_total) * 100);
if (percent != this.progressCount)
{
Ext.getDom('progressBar_' + file.id).style.width = percent + "%";
Ext.getDom('progressText_' + file.id).innerHTML = percent + " %";
this.progressCount = percent;
}

//console.info(percent);

this.store.getById(file.id).set('status', 1);

//this.store.getById(file.id).commit();
//this.progress_bar.updateProgress(bytes_completed/bytes_total, String.format(this.strings.text_uploading, file.name, this.formatBytes(bytes_completed), this.formatBytes(bytes_total)));

this.fireEvent('uploadProgress', this, file, bytes_completed, bytes_total);
},

/**
* SWFUpload uploadError event
* Show notice when error occurs
* @param {Object} file
* @param {Integer} error
* @param {Integer} code
* @return {}
*/
uploadError: function(file, error, code) {
if(this.debug) console.info('UPLOAD ERROR');
if (code==500)
{
Ext.MessageBox.alert(this.strings.text_error, "File too big");
this.fireEvent('fileUploadError', this, file, error, code);
return;
}
switch (error) {
case -200:
Ext.MessageBox.alert(this.strings.text_error, this.strings.error_file_not_found);
break;

case -230:
Ext.MessageBox.alert(this.strings.text_error, this.strings.error_security_error);
break;

case -290:
this.store.getById(file.id).set('status', 4);
this.store.getById(file.id).commit();
break;
}

this.fireEvent('fileUploadError', this, file, error, code);
},

/**
* SWFUpload uploadSuccess event
* @param {Object} file
* @param {Object} response
*/
uploadSuccess: function(file, response) {
if(this.debug) console.info('UPLOAD SUCCESS');

var data = Ext.decode(response);
if (data.success) {
this.store.getById(file.id).data.fileState = SWFUpload.FILE_STATUS.COMPLETE;
this.store.getById(file.id).set('status', 2);
//this.store.remove(this.store.getById(file.id));
} else {
this.store.getById(file.id).set('status', 3);
this.store.getById(file.id).commit();
if (data.msg) {
Ext.MessageBox.alert(this.strings.text_error, data.msg);
}
}


this.fireEvent('fileUploadSuccess', this, file, data);
},

/**
* SWFUpload uploadComplete event
* @param {Object} file
*/
uploadComplete: function(file) {
if(this.debug) console.info('UPLOAD COMPLETE');

this.progress_bar.reset();
this.progress_bar.updateText(this.strings.text_progressbar);

if(this.suo.getStats().files_queued && !this.upload_cancelled) {
this.suo.startUpload();
} else {
this.fireEvent('fileUploadComplete', this, file);

this.allUploadsComplete();
}

},

/**
* SWFUpload allUploadsComplete method
*/
allUploadsComplete: function() {
this.cancelBtn.hide();
this.addBtn.show();
this.clearBtn.show();

this.fireEvent('allUploadsComplete', this);
},

/**
* SWFUpload setPostParams method
* @param {String} name
* @param {String} value
*/
addPostParam: function(name, value) {
if (this.suo) {
this.suo.settings.post_params[name] = value;
this.suo.setPostParams(this.suo.settings.post_params);
} else {
this.post_params[name] = value;
}
},

/**
* Start file upload
* SWFUpload startUpload method
*/
startUpload: function() {
if(this.debug) console.info('START UPLOAD');

this.cancelBtn.show();
this.uploadBtn.hide();
this.clearBtn.hide();
// this.addBtn.hide();

this.upload_cancelled = false;

this.fireEvent('startUpload', this);

this.suo.startUpload();
},

/**
* SWFUpload stopUpload method
* @param {Object} file
*/
stopUpload: function(file) {
if(this.debug) console.info('STOP UPLOAD');

this.suo.stopUpload();

this.upload_cancelled = true;

this.getStore().each(function() {
if (this.data.status == 1) {
this.set('status', 0);
this.commit();
}
});

this.cancelBtn.hide();
if (this.suo.getStats().files_queued > 0) {
this.uploadBtn.show();
}
this.addBtn.show();
this.clearBtn.show();

this.progress_bar.reset();
this.progress_bar.updateText(this.strings.text_progressbar);

},

/**
* Delete one or multiple rows
* SWFUpload cancelUpload method
*/
removeFiles: function() {
if(this.debug) console.info('REMOVE FILES');

var selRecords = this.getSelections();
for (var i=0; i < selRecords.length; i++) {
if (selRecords[i].data.status != 1) {
this.suo.cancelUpload(selRecords[i].id);
this.store.remove(selRecords[i]);
}
}

if (this.suo.getStats().files_queued === 0) {
this.uploadBtn.hide();
// this.clearBtn.hide();
}

this.fireEvent('removeFiles', this);
},

/**
* Clear the Queue
* SWFUpload cancelUpload method
*/
removeAllFiles: function() {
if(this.debug) console.info('REMOVE ALL');

// mark all internal files as cancelled
var files_left = this.suo.getStats().files_queued;

while (files_left > 0) {
this.suo.cancelUpload();
files_left = this.suo.getStats().files_queued;
}

this.store.removeAll();

this.cancelBtn.hide();
this.uploadBtn.hide();
// this.clearBtn.hide();

this.fireEvent('removeAllFiles', this);
}

});

nikolayLevin
29 Jul 2010, 1:07 AM
how does SWFupload work ? Does swf plugin make upload progress ? or javascript make upload progress ?

Ratan
5 Jan 2011, 7:05 AM
Hi Santosh,
This link http://showcase.rumsan.com/swfupload/ is not working anymore- Any ideas on how to access the page

msinn
5 Jan 2011, 7:52 AM
Hi Santosh,
This link http://showcase.rumsan.com/swfupload/ is not working anymore- Any ideas on how to access the page

that's right, but you can use the code posted by tobiu in #32

Ratan
5 Jan 2011, 8:06 AM
Thanks msinn. I was wondering if I can see the page working somewhere. Great! I appreciate your prompt reply!

santoshrestha
23 Jan 2011, 9:12 PM
Thanks msinn. I was wondering if I can see the page working somewhere. Great! I appreciate your prompt reply!

I will try to bring it online.

THanks,
SAntosh

mschwartz
24 Jan 2011, 6:26 AM
See bbarCfg option of Ext.Panel. You should be able to use something besides a toolbar there, to get 100% width of progress bar.