how to send png image from server to display in browser via ajax

前端 未结 4 637
别跟我提以往
别跟我提以往 2021-01-04 09:37

I have been having a hard time with what must be an incredibly normal task. I upload and save images to my web server and save the path to the file in MySQL data base (this

4条回答
  •  -上瘾入骨i
    2021-01-04 10:40

    You can actually embed image data inside the img tag in the browser, therefore ajax code could look like this:

    $.ajax({
        url: get_image.php,
        success: function(image_string){
            $(document.body).append(");
        }
    });
    

    Note that you will need to write this base64_encode function. Have a look at this question - the function is given there.

提交回复
热议问题