Search code examples
file-uploadfilteryuialfrescoalfresco-share

Alfresco Share File upload filter


My file upload filter does not work with Alfresco YUI (or flash?) upload. I have the following piece of code:

        if (null == this.fileUpload) {
            this.fileUpload = Alfresco.getFileUploadInstance();
        }
        var filter = new Array({description:"Images", extensions:"*.jpg;*.png;*.gif"});
        var uploadConfig = {
            mode: this.fileUpload.MODE_SINGLE_UPLOAD
            , username: Alfresco.constants.USERNAME
            , siteId: Alfresco.constants.SITE
            , uploadDirectory: '/'
            , containerId: 'Logo'
            , filter: filter
            , onFileUploadComplete: {
                fn: this.onFileUploadComplete
                , scope: this
            }
        };
        this.fileUpload.show(uploadConfig);

This is all cool and upload of files work. I can upload files and there are no issues. But the problem is that the filter does not. What am I missing in this config?

I'm working with Alfresco Share Community version 4.2c.


Solution

  • zladuric,

    I believe the filters have to be defined individually. The following worked for me:

    this.fileUpload = Alfresco.getFileUploadInstance();
    var description = "Images";
    var extensions = ["*.jpeg", "*.jpg", "*.png", "*.gif"];
    var filter = new Array(
        {description: description, extensions: extensions[0]},
        {description: description, extensions: extensions[1]},
        {description: description, extensions: extensions[2]},
        {description: description, extensions: extensions[3]}
    );
    var uploadConfig = {...};
    this.fileUpload.show(uploadConfig);    
    

    I hope this helps.