Page 2 of 43 FirstFirst 123412 ... LastLast
Results 11 to 20 of 424

Thread: [2.0] Ext.ux.UploadDialog extension.

  1. #11
    franckxx
    Guest

    Default Yeahh !

    Impressive Work !

    Thx for share this nice stuff !

  2. #12

  3. #13
    Ext User
    Join Date
    Nov 2007
    Posts
    47

    Thumbs up Thanks!

    Thanks! This is really what I needed, very nice work

    Just one question: Is there a way to limit the number of uploads?

  4. #14
    Sencha Premium Member MaximGB's Avatar
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    542

    Default

    You can use filetest event for this purpose. On each filetest event you should increment a counter, and if counter is more then required number then you should return false from the handler.
    Use the force - read the source.

  5. #15

    Default

    First of all great work!

    Is there any way to add multiple files. It's very onerous to click "add" all the time if you want to add some files.

    Regards

  6. #16
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    Quote Originally Posted by vipcop View Post
    First of all great work!

    Is there any way to add multiple files. It's very onerous to click "add" all the time if you want to add some files.

    Regards
    unless you use flash, no.

  7. #17
    Ext User
    Join Date
    Nov 2007
    Posts
    47

    Default

    Quote Originally Posted by MaximGB View Post
    You can use filetest event for this purpose. On each filetest event you should increment a counter, and if counter is more then required number then you should return false from the handler.
    Can you post a little example? I'm kind of new to ExtJS.

    Code:
    permitted_extensions: ['jpg', 'jpeg', 'gif']
    Adding this to my dialog does not work. I get a "wrong file" window every time. No matter what file is chosen.

  8. #18
    Sencha Premium Member MaximGB's Avatar
    Join Date
    Jun 2007
    Location
    Moscow, Russia
    Posts
    542

    Default

    Quote Originally Posted by alos View Post
    Can you post a little example? I'm kind of new to ExtJS.

    Code:
    permitted_extensions: ['jpg', 'jpeg', 'gif']
    Adding this to my dialog does not work. I get a "wrong file" window every time. No matter what file is chosen.
    Do you have the last extension version? There was a bug fix at 28 of December.
    Post your code here, or give me a link to a page where I can see the bug you talking about.
    Use the force - read the source.

  9. #19
    Ext User
    Join Date
    Nov 2007
    Posts
    47

    Talking

    Upon further testing it seams that only some files that end with ".jpg" work but not files with ".JPG". My mistake I suppose. Sorry!

    Now, about the filetest. Is this correct?

    Code:
    	function getDialog()
    		{
    			if (!dialog) {
    				dialog = new Ext.ux.UploadDialog.Dialog({
    					url: 'upload-dialog-request.php',
    					reset_on_hide: false,
    					allow_close_on_upload: true,
    					upload_autostart: true,
    					permitted_extensions: ['jpg', 'jpeg', 'gif'],
    					filetest: cuenta
    				});
    				dialog.on('uploadsuccess', onUploadSuccess);
    			}
    			return dialog;
    		}
    		function subirRevista(){
    			var lugar = Ext.getCmp('botonPaSubir');
    			getDialog().show();
    		}
    			
    		function cuenta(){
    			contador++;
    			if(contador>1){
    				return false;
    			}
    			return true;
    		}
    		
    		function onUploadSuccess(dialog, filename, resp_data)
    		{
    			var parts = filename.split(/\/|\\/);
    			if (parts.length == 1) {
    				filename = parts[0];
    			}
    			else {
    				filename = parts.pop();
    			}
    			file_list_tpl.append('file-list', {name: filename});
    		}

  10. #20

    Wink

    Alos, Max,

    I think I found a small uncorrected bug (I just checked...)
    In line 540, it is necessary to replace:
    Code:
    predicate: [this.fireFileTestEvent, this.isPermittedFileType],
    with
    Code:
    predicate: [this.fireFileTestEvent, this.isPermittedFile],
    I tested it, and it works much better...

    Also, in case you'd like (or have time for, or both) to add progress bars, I think 2 progress bars would be great (one for the Current file, one for the Total).
    For that, you could make a great use of the emdev uploadprogress PHP extension.
    Both a demo and the DLL file for Windows PHP >5.2.0 are available here (watch out 'coz further versions don't work correctly as far as I tried them):
    http://www.emforge.org/wiki/AjaxBasedFileUploadForPHP

    To get it to work correctly, if you've got a Windows-based setup, you need to copy the DLL file into you PHP /EXT folder, and to add the following to your PHP.INI file:
    [uploadprogress]
    extension=php_uploadprogress.dll
    uploadprogress.file.filename_template="D:\server\tmp\upt_%s.txt"
    and replace "D:\server\tmp\" with your Apache or PHP temp folder...

    Then, your <INPUT TYPE="FILE" ...> form needs to be added with something like that:
    HTML Code:
    '<input type="hidden" id="hidUploadID" class="upcls" name="UPLOAD_IDENTIFIER" id="UPLOAD_IDENTIFIER" value="' + upID + '" />'
    and your upID defined somewhat like this:
    Code:
    var upID = new String(Math.floor(Math.random() * 65535));
    var curDate = new Date();     
    upID += new String(curDate.getMilliseconds());
    Then, each time you want to update your progress bar, you need to call this function in PHP:
    uploadprogress_get_info($upID)
    which returns a structure like that (C-code returned to PHP):
    [
    time_t time_start;
    time_t time_last;
    unsigned int speed_average;
    unsigned int speed_last;
    unsigned long bytes_uploaded;
    unsigned long bytes_total;
    unsigned int files_uploaded;
    int est_sec;
    ]


    Eventually, to avoid the lowercase/uppercase prolem with file extensions comparisons, we could use sthg like that in line 966 of your code. Replace:
    Code:
    result = this.permitted_extensions.indexOf(this.getFileExtension(filename)) != -1;
    with
    Code:
    result = this.permitted_extensions.indexOf(this.getFileExtension(filename).toLowerCase()) != -1;
    and force the permitted_extensions, when set, to all be converted to lowercase... For example, in lines 469-470:
    Replace
    Code:
      config = Ext.applyIf(config || {}, default_config);
      config.layout = 'absolute';
    with
    Code:
      config = Ext.applyIf(config || {}, default_config);
      this.formatPermittedExtensions();
      config.layout = 'absolute';
    and add before line 915:
    Code:
    formatPermittedExtensions: function() {
      if (this.permitted_extensions.length > 0) {
      for (var (i = 0 ; i < this.permitted_extensions.length ; i++)
        this.permitted_extensions[i] = this.permitted_extensions[i].toLowerCase();
      }
    },
    and replace, at line 1462:
    Code:
        this.permitted_extensions = value;
    with
    Code:
        this.permitted_extensions = value;
        this.formatPermittedExtensions();
    Hope this will help... I make great use of your extension right now, and thought I would try to share my latest trials...

    Very respectfully,
    Mehdi DHAKOUANI

Page 2 of 43 FirstFirst 123412 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •