I have implemented file sharing on my liveagent chat application.

I have added following line in my custom chat vf page. And now I am able to share file over chat from client side.

<liveAgent:clientChatFileTransfer />

Can we restrict the file type for client. Like I want that client will be only able to share text file.

Is it possible in salesforce ?


As I know, unfortunately it's impossible now. I've asked the Salesforce support about that I got the next answer:

I understand that you submitted a case regarding restricting types of transferring files.

I would like to apologize as the standard behavior currently is that the file size limit is the same as the upload file size limit (default, 5MB) and there is no limit on the format. You can do PDF, JPEG, GIF, etc

Live Agent file transfer uses the same file upload functionality built-in in salesforce wherein All file types are supported, including everything from Microsoft® PowerPoint presentations and Excel spreadsheets, to Adobe® PDFs, image files, audio files, and video files except that there is file size limit.

Upload Files: https://help.salesforce.com/apex/HTViewHelpDoc?id=collab_files_uploading.htm&language=en


It is unfortunate that Salesforce officially does not support this. But you can restrict the file types through JavaScript.

If you do a view-source of the client chat window you can see Salesforce generate the below HTMl code for <liveAgent:clientChatFileTransfer /> Visualforce component.

<input id="fileSelectInput" name="file" type="file" />

This is a normal file type input element with id="fileSelectInput". So in JS you can get this element and implement your own logic to restric the file types.

Here is a working version of the JS code, you can put in the chat vf page. Update the file types as per your requirement.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">          
    var jq = $.noConflict();
        jq('#fileSelectInput').change(function () {
            var ext = jq('#fileSelectInput').val().split('.').pop().toLowerCase();
            if(jq.inArray(ext, ['gif','png','jpg','jpeg']) == -1) {
                alert('This is not an allowed file type.');
                this.value = "";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.