从HTML到数据库获取img

从HTML到数据库获取img

本文介绍了从HTML到数据库获取img的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hej agian

我试图在将其上传到我的数据库之前预览我的图像,所以我使用javascript它的工作与HTML img但不是asp图像。



所以现在我试图将图像从html标签img保存到我的数据库中。

问题我不能抓住元素img!在代码behinde

有没有可能的方式存储在我的数据库中_



我尝试过:



函数showpreview(输入){



if(input.files&& input.files [ 0]){



var reader = new FileReader();

reader.onload = function(e){

$('#imgpreview')。css('visibility','visible');

$('#imgpreview')。attr('src',e.target.result) ;

}

reader.readAsDataURL(input.files [0]);

}



}

hej agian
im trying to preview my image before uploading it to my db , so i used javascript its work with html img but not asp image .

so now im trying to save image into my database from html tag img.
the problem i cant catch the element img ! in code behinde
is there any possible way to store in my database_

What I have tried:

function showpreview(input) {

if (input.files && input.files[0]) {

var reader = new FileReader();
reader.onload = function (e) {
$('#imgpreview').css('visibility', 'visible');
$('#imgpreview').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}

}

推荐答案



<asp:FileUpload ID="myFile" runat="server" onchange="showpreview(this);" />

<img id="imgpreview" />

<asp:Button ID="btnSubmit" OnClick="btnSubmit_Click" runat="server" />

<script type="text/javascript">
    function showpreview(input) {

        if (input.files && input.files[0]) {

            var reader = new FileReader();
            reader.onload = function (e) {


这篇关于从HTML到数据库获取img的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 12:45