How to send an image to a php file

0

I have a problem sending an image to a php file.

To start I have a page with a <form> where I send different data to my php file and then upload them to a database. With this I have no problem.

The problem arises when I also want to send an image that I get through a script to the same php file. I can not think of how to put it in an input and then get it with the POST method.

I hope to have been clear with the query. Thank you very much and I'll leave you a bit of my code below.

Script To get the image:

$(document).on('click', "#testImg" , function() {

    html2canvas($('#map'), {
        useCORS: true,
        onrendered: function (canvas) {
            var img = canvas.toDataURL();
            uploadMap(img,"uploads/mapas");
            $('<img>', {
                src: img
            }).appendTo($('.tst2'));
        }
    });
});

Input where I want to save the image to get it with POST in the php file

<input type="hidden" name="mapRoute" value="">
    
asked by Augusto Vidal Sarmento 19.12.2018 в 15:58
source

0 answers