Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to send an image to server. Image is present in client side in <img> tag

There are ways to perform the image upload if type=“file”. The requirement here is to send an image from image tag to server.

Cannot send by converting into base64. Due to size constrain.

<form id="form-url">
    <image src=“/images/defaultImg.jpg” id=“testImg1”/>
    <image src=“/images/defaultImg2.jpg” id=“testImg2”/>
    <button>UPLOAD onClick=“</button>
</form>

The is how I make an Ajax call.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

$.get(“/appUI/ImageServiceController", {
                                action : “imageCompare”,
                                firstImage:$(‘#testImg1’).attr('src');,
                                secondImage:$(‘#testImg2’).attr('src');,
                }, function(res) {
                                alert(“success”);
                }).fail( function(request, status, errorThrown) {
        alert(“failed”);
                     }
                })
}

How can I upload this image to server.

>Solution :

This is an X/Y problem.

If you serve the image from the same server you have the image already on the server.

If you serve the image from another server you have the URL

If the page that needs the image does not know the URL, then send the URL of the image to the server instead of trying to grab the image from the client

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading