Add accept attribute in upload field properties.

Add accept attribute in upload field properties.

hemendraongraphhemendraongraph Posts: 4Questions: 1Answers: 0

How we can add accept attributes in upload field ?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,146Questions: 1Answers: 2,586
    Answer ✓

    Hi @hemendraongraph .

    Are you referring to uploading files with Editor?

    Cheers,

    Colin

  • hemendraongraphhemendraongraph Posts: 4Questions: 1Answers: 0
    edited August 2019

    Yes I create field through datatables editor fields

    {
    label: "Image:",
    name: "image_link",
    type: "upload",
    display: function ( file_id, counter ) {

    },
    when I click to upload files it's take only pdf files not take other files likes image,vid etc.
    I want to it's work like as accept attributes of file but I don't want to create a seprate template and refer here.

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    Hi @hemendraongraph ,

    If you look at this example here, and click on the "Server script" tab, you'll see the restriction is done on the server end.

    Cheers,

    Colin

  • hemendraongraphhemendraongraph Posts: 4Questions: 1Answers: 0
    edited August 2019

    @colin It's not possible at the server side becuase I does not want to show all files except pdf file while I choosed at the client side.
    Files are choosed from the client side and my Client requirement is not show while choose file.

  • allanallan Posts: 61,732Questions: 1Answers: 10,110 Site admin

    At the moment you need to use the following after initialising the Editor instance:

    editor.field('myField').input().attr('accept', 'application/pdf');
    

    In 1.9.1 you'll be able to pass attributes to the field during initialisation using an attr option.

    Allan

This discussion has been closed.