<tfoot id='COtFJ'></tfoot>
        <bdo id='COtFJ'></bdo><ul id='COtFJ'></ul>

    1. <legend id='COtFJ'><style id='COtFJ'><dir id='COtFJ'><q id='COtFJ'></q></dir></style></legend>

      <i id='COtFJ'><tr id='COtFJ'><dt id='COtFJ'><q id='COtFJ'><span id='COtFJ'><b id='COtFJ'><form id='COtFJ'><ins id='COtFJ'></ins><ul id='COtFJ'></ul><sub id='COtFJ'></sub></form><legend id='COtFJ'></legend><bdo id='COtFJ'><pre id='COtFJ'><center id='COtFJ'></center></pre></bdo></b><th id='COtFJ'></th></span></q></dt></tr></i><div id='COtFJ'><tfoot id='COtFJ'></tfoot><dl id='COtFJ'><fieldset id='COtFJ'></fieldset></dl></div>
    2. <small id='COtFJ'></small><noframes id='COtFJ'>

      1. 如何从 html 图像中获取 base64 编码数据

        How to get base64 encoded data from html image(如何从 html 图像中获取 base64 编码数据)
          <i id='sEmpN'><tr id='sEmpN'><dt id='sEmpN'><q id='sEmpN'><span id='sEmpN'><b id='sEmpN'><form id='sEmpN'><ins id='sEmpN'></ins><ul id='sEmpN'></ul><sub id='sEmpN'></sub></form><legend id='sEmpN'></legend><bdo id='sEmpN'><pre id='sEmpN'><center id='sEmpN'></center></pre></bdo></b><th id='sEmpN'></th></span></q></dt></tr></i><div id='sEmpN'><tfoot id='sEmpN'></tfoot><dl id='sEmpN'><fieldset id='sEmpN'></fieldset></dl></div>
          <legend id='sEmpN'><style id='sEmpN'><dir id='sEmpN'><q id='sEmpN'></q></dir></style></legend>

            <small id='sEmpN'></small><noframes id='sEmpN'>

            • <bdo id='sEmpN'></bdo><ul id='sEmpN'></ul>
                <tbody id='sEmpN'></tbody>
              <tfoot id='sEmpN'></tfoot>

                  本文介绍了如何从 html 图像中获取 base64 编码数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个注册表单,用户可以在其中选择头像.他们有两种可能:

                  I have a registration form where users can choose an avatar. They have 2 possibilities:

                  1. 选择默认头像
                  2. 上传自己的头像

                  在我的 HTML 页面中有这个.

                  In my HTML page I have this.

                  <img id="preview" src="img/default_1.png">
                  

                  它显示选择的头像.我使用 File Api 让用户上传自己的图像.这使得 HTML 图像的 src 变成了这样.

                  It displays the chosen avatar. I use the File Api to let users upload their own image. That makes the src of the HTML image to something like this.

                  <img id="preview" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgA... />
                  

                  当他们发布注册表单时.数据将被发送到 REST 服务.当用户自己上传头像时,我可以发送 base64 编码数据.但是如何处理默认头像?它是一个 url 而不是 base64 编码的数据.

                  When they post the registration form. The data will be sent to a REST service. I can send the base64 encoded data when a user uploaded an avatar himself. But how do I handle the default avatar? It is an url instead of base64 encoded data.

                  推荐答案

                  你可以试试下面的例子http://jsfiddle.net/xKJB8/3/

                  <img id="preview" src="http://www.gravatar.com/avatar/0e39d18b89822d1d9871e0d1bc839d06?s=128&d=identicon&r=PG">
                  <canvas id="myCanvas" />
                  

                  <小时>

                  var c = document.getElementById("myCanvas");
                  var ctx = c.getContext("2d");
                  var img = document.getElementById("preview");
                  ctx.drawImage(img, 10, 10);
                  alert(c.toDataURL());
                  

                  这篇关于如何从 html 图像中获取 base64 编码数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Fetch multiple links inside foreach loop(在 foreach 循环中获取多个链接)
                  Backbone Fetch Request is OPTIONS method(Backbone Fetch Request 是 OPTIONS 方法)
                  Fetch API leaks memory in Chrome(Fetch API 在 Chrome 中泄漏内存)
                  How can I download and save a file using the Fetch API? (Node.js)(如何使用 Fetch API 下载和保存文件?(Node.js))
                  Send blob data to node using fetch, multer, express(使用 fetch、multer、express 将 blob 数据发送到节点)
                  Sending a custom User-Agent string along with my headers (fetch)(发送自定义用户代理字符串以及我的标头(获取))
                • <small id='eVE7q'></small><noframes id='eVE7q'>

                    <i id='eVE7q'><tr id='eVE7q'><dt id='eVE7q'><q id='eVE7q'><span id='eVE7q'><b id='eVE7q'><form id='eVE7q'><ins id='eVE7q'></ins><ul id='eVE7q'></ul><sub id='eVE7q'></sub></form><legend id='eVE7q'></legend><bdo id='eVE7q'><pre id='eVE7q'><center id='eVE7q'></center></pre></bdo></b><th id='eVE7q'></th></span></q></dt></tr></i><div id='eVE7q'><tfoot id='eVE7q'></tfoot><dl id='eVE7q'><fieldset id='eVE7q'></fieldset></dl></div>
                    • <bdo id='eVE7q'></bdo><ul id='eVE7q'></ul>
                        <tbody id='eVE7q'></tbody>
                    • <legend id='eVE7q'><style id='eVE7q'><dir id='eVE7q'><q id='eVE7q'></q></dir></style></legend>

                          <tfoot id='eVE7q'></tfoot>