cancel
Showing results for 
Search instead for 
Did you mean: 

FileUpload, customised header?

sunquanbin
Champ on-the-rise
Champ on-the-rise
Hi,

Can I ask how to provide a customised header to the default share FileUpload.

By the default share FileUpload, I mean this one:


   var uploader = Alfresco.getFileUploadInstance();
        var uploadConfig = {
          siteId: {string}, // site to upload file(s) to
          containerId: {string}, // container to upload file(s) to (i.e. a doclib id)
          destination: {string}, // destination nodeRef to up}
          …..
         };
        uploader.show(uploadConfig);

        // SOME CODE TO CHANGE THE UPLOADER'S DEFAULT HEADER
        uploader.setHeader("Custom Header"); // no such method, so how I can achieve this?


The above code will pop-up a FileUpload window. The window has a default header "Upload File" or "Upload File(s)" depending on whether is single or multi upload. How can I change this header to my custom header, e.g. "Upload a picture"

Thanks,

Sun
4 REPLIES 4

romschn
Star Collaborator
Star Collaborator
The default header text appears from \tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\upload\flash-upload.get.properties and flash-upload.get_en.properties

header.singleUpload=Upload File
header.multiUpload=Upload File(s)

You can modify the text as you required to display the out-of-the-box flash-upload component with your custom header text.

Thanks for the reply. I noticed by changing the properties file will have a global effect which is not quite the thing I want to do.

I would like to dynamically set the header in the javacript file individually, i.e. in the code above calling the FileUpload so that different headers can be display in different places.

regards,

romschn
Star Collaborator
Star Collaborator
Okay got your point.
There is one way to achieve this by implementing as following.
1. While you are getting instance of Uploader, currently it takes the kind of upload from mode attribute.
2. Customize flash-upload.js and define your custom modes. e.g. MODE_IMAGE_UPLOAD_SINGLE etc same way as existing MODE_SINGLE_UPLOAD etc are defined at code section under below "YAHOO.extend(Alfresco.FlashUpload, Alfresco.component.Base,"
3. Then under       _applyConfig: function FlashUpload__applyConfig(), pickup the property value based on the selected mode. Currently it takes the prpoerty values i mentioned earlier based on the value of MODE_SINGLE_UPLOAD etc.

Please try this and see if it works for you or not. Hope this helps.

sunquanbin
Champ on-the-rise
Champ on-the-rise
Many thanks for the suggestion. But I consider this seems an overkill for my purpose plus I don't want to overwrite the existing system files.

Actually, this can be achieved by modifying the relevant field in the uploader object after show(config).


uploader.show(uploadConfig);
uploader.uploader.titleText.textContent = "Custom Title";


I originally thought this can be achieved via the config or some simple setter method. But now it seems that direct hack is the most convenient way. Thanks for the reply anyway.

Regards,

Sun