Images cannot save into the localhost folder location

試著忘記壹切 提交于 2020-06-29 04:13:12

问题


I am create a function to download the images into my localhost folder, but it cannot save it to the localhost folder, because I am using the localhost to create the function. Hope someone can guide me how to solve it the problem.

Below is my coding:

<input id="btn-Preview-Image" type="button" value="Download"/>

<script>
      $(document).ready(function(){


        var element = $("#html-content-holder"); // global variable
        var getCanvas; // global variable

        $("#btn-Preview-Image").on('click', function () {
          html2canvas(element, {
            onrendered: function (canvas) {
              // $("#previewImage").append(canvas);
              getCanvas = canvas;

              $("#btn-Convert-Html2Image").trigger('click');

            }
          });
        });

        $("#btn-Convert-Html2Image").on('click', function () {
          // Now browser starts downloading it instead of just showing it
          //var newData = imgageData.replace(/^data:image\/png/, "data:application/octet-stream");
          // $("#btn-Convert-Html2Image").attr("download", "your_pic_name.png").attr("href", newData);
          const link = document.createElement('a');
          link.download = 'your_pic_name.png';
          link.href = getCanvas.toDataURL("./qr0601/images/image/png")
          link.click();
        });

      });
</script>

The output like below the picture:

This is my working fiddle: https://jsfiddle.net/ason5861_cs/1a9mdf2t/

I need to save the file path is here C:\xampp\htdocs\qr0601\images. How to download the image save the location in the C:\xampp\htdocs\qr0601\images ?

来源:https://stackoverflow.com/questions/62149036/images-cannot-save-into-the-localhost-folder-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!