protected void btnSave_Click(object sender, EventArgs e)
{
//Get Image into byte
Stream fs = FileUpload1.PostedFile.InputStream;
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);
{
//Get Image into byte
Stream fs = FileUpload1.PostedFile.InputStream;
BinaryReader br = new BinaryReader(fs);
Byte[] bytes = br.ReadBytes((Int32)fs.Length);
}
In .aspx
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#blah').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
</script>
<table>
<tr>
<td colspan="2" style="border:1px #ccc solid; padding:10px;" >
EmpId
<asp:TextBox ID="txtEmpId" runat="server"></asp:TextBox>
</td>
<td align="right" style="border:1px #ccc solid; padding:20px;">
Upload Photo
<asp:FileUpload ID="FileUpload1" runat="server" onchange="readURL(this)" Width="250px" style="border:1px #ccc solid;" />
</td>
<td width="150px" style="border:1px #ccc solid; padding:10px;">
<img id="blah" src="../../Images/View/ad1.jpg" alt="" style="height:150px; width:150px;" />
</td>
</tr>
</table>
No comments:
Post a Comment