Set a different URL for uploadMany field

Set a different URL for uploadMany field

Lucho_1312Lucho_1312 Posts: 30Questions: 9Answers: 0

Hi!

I'm trying to set a different URL to use the uploadMany field, but it only seems to use the URL of the page I'm in.

Is there a way to set an special URL for this case? I cannot use the same URL that is set in the ajax property when I set the editor, because I'm setting it for a rest application in the backend.

Thanks!
Luciano

Replies

  • allanallan Posts: 63,258Questions: 1Answers: 10,421 Site admin

    Hi,

    Can you show me the Javascript you are using for the Editor initialisation please?

    Thanks,
    Allan

  • Lucho_1312Lucho_1312 Posts: 30Questions: 9Answers: 0

    Sure,

    This is the initialization code:

    var editor = new $.fn.dataTable.Editor({
        ajax: {
            "create": "/crud/products/items",
            "edit": {
                "url": "/crud/products/items/_id_",
                "method": "PUT"
            },
            "remove": "/crud/products/items/_id_"
        },
        legacyAjax: false,
        table: dataTable,
        idSrc: "_id",
        fields: [{
            "label": "Images",
            "labelInfo": "",
            "message": "",
            "data": "mediaFiles.images",
            "name": "mediaFiles.images[].id",
            "className": "",
            "validation": {},
            "dependentOn": {},
            "type": "uploadMany",
            "noImageText": "No images"
        }, {
            "label": "SKU",
            "labelInfo": "",
            "message": "",
            "data": "sku",
            "name": "sku",
            "className": "required",
            "validation": {
                "required": "El campo SKU es obligatorio"
            },
            "dependentOn": {}
        }, {
            "label": "Nombre",
            "labelInfo": "",
            "message": "",
            "data": "title",
            "name": "title",
            "className": "required",
            "validation": {
                "required": "El campo Nombre es obligatorio"
            },
            "dependentOn": {}
        }],
        formOptions: {
            bubble: {
                buttons: false,
                submitOnBlur: true
            }
        }
    });
    
    

    When I upload a picture, I just get a POST in the same URL that the page is. (in this case, it goes to "/products/items.html"

    Thanks!
    Luciano

  • allanallan Posts: 63,258Questions: 1Answers: 10,421 Site admin

    Hi Luciano,

    Thanks for the Javascript. There is an ajax option for the uploadMany (and also upload) which provides the ability to set a separate URL for how the file should be uploaded.

    See the Options section of the uploadMany reference documentation.

    Allan

This discussion has been closed.