日期:2014-05-17 浏览次数:20423 次
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Default</title> <style type="text/css"> #imgPreview { filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale'); width:220px; height:220px; overflow:hidden; } </style> <script src="Scripts/jquery.min.js" type="text/javascript"></script> <script src="Scripts/jquery.Jcrop.min.js" type="text/javascript"></script> <script src="Scripts/jquery.imgareaselect.min.js" type="text/javascript"></script> <link href="Styles/jquery.Jcrop.min.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="form1" name="form1" method="post" runat="server"> <div id="divContainer"> <input class="input_file" type="file" id="file1" onchange="fnPreview();" /> <br /><br /> <img id="imgPreview" border="0" src="data:image/gif;base64,R0lGODlhAQABAJEAAAAAAP///////wAAACH5BAEAAAIALAAAAAABAAEAAAICVAEAOw==" /> </div> </form> <script type="text/javascript"> var ipv = document.getElementById("imgPreview"); function fnPreview() { var file = document.getElementById("file1"); if (file.files && file.files[0]) { var reader = new FileReader(); reader.onload = function (evt) { ipv.src = evt.target.result; } reader.readAsDataURL(file.files[0]); } else { file.select(); var src = document.selection.createRange().text; ipv.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = src; } } $(document).ready(function () { $('#imgPreview').click(function () { $('#imgPreview').imgAreaSelect({ maxWidth: 200, maxHeight: 150, handles: true }); }) }); </script> </body> </html>