Freetextbox1.63问题? 各位大哥,谁有Freetextbox1.63的修改后的文件上传限定大小,图片加水印,上传图是可以预览的源代码呀!能发给我一下吗?chf99cn@vip,jx163.com,感谢大家了!我现在有时插入图时,有时可以打开窗口,有时一页都是空白,各位高手,能给个答案吗?谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我自己改的,有点乱,能预览,控制大小的话就去web.config里控制一下吧,不过没有水印的效果<%@ Page language="c#" %><script runat="server">private string NoFileMessage = "您没有选择文件。";private string UploadSuccessMessage = "上传成功";private string UploadFailureMessage = "上传失败。";private string NoFolderSpecifiedMessage = "您要上传到的文件夹不存在。";private string InvalidFileTypeMessage = "您无法上传这种类型的文件。";private string[] AcceptedFileTypes = new string[] {"jpg","jpeg","gif","JPG","JPEG","GIF"};private string DefaultImageFolder = "upimages"; // 默认的起始文件夹private void Page_Load(object sender, System.EventArgs e) { string isframe = "" + Request["frame"]; if (isframe != "") { MainPage.Visible = true; iframePanel.Visible = false; string FileErrorMessage = "只允许上传以下类型的文件:"; string ValidationString = ".*("; for (int i=0;i<AcceptedFileTypes.Length; i++) { ValidationString += "[\\." + AcceptedFileTypes[i] + "]"; if (i < (AcceptedFileTypes.Length-1)) ValidationString += "|"; FileErrorMessage += AcceptedFileTypes[i]; if (i < (AcceptedFileTypes.Length-1)) FileErrorMessage += ", "; } FileValidator.ValidationExpression = ValidationString+")$"; FileValidator.ErrorMessage=FileErrorMessage; } else { }}public void UploadImage_OnClick(object sender, EventArgs e) { if ( UploadFile.PostedFile.FileName.ToString().Trim() != "" ) { string AppPath = HttpContext.Current.Request.PhysicalApplicationPath; string AppUrl; if (Request.ApplicationPath == "/") AppUrl = Request.ApplicationPath; else AppUrl = Request.ApplicationPath + "/"; string ImageFileLocation = AppUrl; ImageFileLocation = ImageFileLocation.Substring(ImageFileLocation.LastIndexOf("\\")+1); ImageFileLocation += DefaultImageFolder; ImageFileLocation += "/"; string UploadFileName = ""; string UploadFileDestination = ""; UploadFileName = UploadFile.PostedFile.FileName; UploadFileName = UploadFileName.Substring(UploadFileName.LastIndexOf("\\")+1); string ImageFileExtention = UploadFileName.Substring(UploadFileName.LastIndexOf(".")); UploadFileDestination = HttpContext.Current.Request.PhysicalApplicationPath; UploadFileDestination += DefaultImageFolder; UploadFileDestination += "\\"; string NewFileName = DateTime.Now.Year.ToString()+DateTime.Now.Month.ToString()+DateTime.Now.Day.ToString()+DateTime.Now.Hour.ToString()+DateTime.Now.Minute.ToString()+DateTime.Now.Second.ToString(); UploadFile.PostedFile.SaveAs(UploadFileDestination + NewFileName + ImageFileExtention); System.Drawing.Image image = System.Drawing.Image.FromFile(UploadFileDestination + NewFileName + ImageFileExtention); Response.Write("<script>var arr=new Array();arr['filename']='"+ImageFileLocation+NewFileName + ImageFileExtention+"';arr['width']='"+image.Width+"';arr['height']='"+image.Height+"';window.parent.returnValue = arr;window.parent.close();<" + "/" + "script>"); }}private bool IsValidFileType(string FileName) { string ext = FileName.Substring(FileName.LastIndexOf(".")+1,FileName.Length-FileName.LastIndexOf(".")-1); for (int i=0; i<AcceptedFileTypes.Length; i++) { if (ext == AcceptedFileTypes[i]) { return true; } } return false;}</script><asp:panel id="MainPage" runat="server" visible="false"><!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML><HEAD><META HTTP-EQUIV="Expires" CONTENT="0"><title>插入图片</title><style>body { margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; background: #ffffff; width: 100%; overflow:hidden; border: 0;}body,tr,td { color: #000000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;}div.imagespacer { width: 120; height: 126; text-align: center; float: left; font: 10pt verdana; margin: 5px; overflow: hidden;}div.imageholder { margin: 0px; padding: 0px; border: 1 solid #CCCCCC; width: 100; height: 100;}div.titleholder { font-family: ms sans serif, arial; font-size: 8pt; width: 100; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; } </style><script language="javascript">lastDiv = null;function divClick(theDiv,filename) { if (lastDiv) { lastDiv.style.border = "1 solid #CCCCCC"; } lastDiv = theDiv; theDiv.style.border = "2 solid #316AC5"; document.getElementById("FileToDelete").value = filename;} function showimg(){document.all.imgview.innerHTML="<img src='"+document.all.UploadFile.value+"'>";} function returnImage(imagename,width,height) { var arr = new Array(); arr["filename"] = imagename; arr["width"] = width; arr["height"] = height; window.parent.returnValue = arr; window.parent.close(); } </script> </HEAD><body><table width=100% height=100% cellpadding=0 cellspacing=0 border=0><FORM encType="multipart/form-data" runat="server" ID="Form1"><tr><td> <div id="galleryarea" style="width=100%; height:100%; overflow: auto;"> <asp:label id="gallerymessage" runat="server"></asp:label> <asp:panel id="GalleryPanel" runat="server"></asp:panel><span id="imgview"></span> </div></td></tr><asp:Panel id="UploadPanel" runat="server"><tr><td height=16 style="padding-left:10px;border-top: 1 solid #999999; background-color:#99ccff;"> <table><tr> <td valign=top><input id="UploadFile" type="file" name="UploadFile" onchange="showimg()" runat="server" style="width:300;"/></td> <td valign=top><asp:button id="UploadImage" Text="上传" runat="server" onclick="UploadImage_OnClick" /></td> </tr> <tr> <td colspan=3> <asp:RegularExpressionValidator runat="server" ControlToValidate="UploadFile" id="FileValidator" display="dynamic"/> <asp:literal id="ResultsMessage" runat="server" /> </td> </tr></table> <input type="hidden" id="RootImagesFolder" Value="images" runat="server" NAME="RootImagesFolder"/> </td></tr></asp:panel></form></table></body></HTML></asp:panel><asp:panel id="iframePanel" runat="server" ><html> <head><title>插入图片</title></head><style>body { margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px; background: #ffffff; overflow:hidden;}</style><body> <iframe style="width:100%;height:100%;border:0;" border=0 frameborder=0 src="ftb.imagegallery.aspx?frame=1&<%=Request.QueryString%>"></iframe></body></html></asp:panel> 如何在界面刷新之后调用一个函数 C# 采集语音 高手请进----有谁有办法抓取chunked 网页 SQL 查询表如何自己关联 +++高分求,软件项目文档+++ javascript怎么取CS文件中的变量值??? 急救 怎样发布 上海从cs转bs 找工作真不好找 怎么判断时间是否在本月呢? asp.net手机网站测试和发布问题 困惑的问题! freetextbox解析??
<script runat="server">private string NoFileMessage = "您没有选择文件。";
private string UploadSuccessMessage = "上传成功";
private string UploadFailureMessage = "上传失败。";
private string NoFolderSpecifiedMessage = "您要上传到的文件夹不存在。";
private string InvalidFileTypeMessage = "您无法上传这种类型的文件。";
private string[] AcceptedFileTypes = new string[] {"jpg","jpeg","gif","JPG","JPEG","GIF"};private string DefaultImageFolder = "upimages"; // 默认的起始文件夹private void Page_Load(object sender, System.EventArgs e)
{
string isframe = "" + Request["frame"];
if (isframe != "")
{
MainPage.Visible = true;
iframePanel.Visible = false; string FileErrorMessage = "只允许上传以下类型的文件:";
string ValidationString = ".*(";
for (int i=0;i<AcceptedFileTypes.Length; i++)
{
ValidationString += "[\\." + AcceptedFileTypes[i] + "]";
if (i < (AcceptedFileTypes.Length-1)) ValidationString += "|";
FileErrorMessage += AcceptedFileTypes[i];
if (i < (AcceptedFileTypes.Length-1)) FileErrorMessage += ", ";
}
FileValidator.ValidationExpression = ValidationString+")$";
FileValidator.ErrorMessage=FileErrorMessage; } else {
}
}public void UploadImage_OnClick(object sender, EventArgs e)
{
if ( UploadFile.PostedFile.FileName.ToString().Trim() != "" )
{
string AppPath = HttpContext.Current.Request.PhysicalApplicationPath;
string AppUrl;
if (Request.ApplicationPath == "/")
AppUrl = Request.ApplicationPath;
else
AppUrl = Request.ApplicationPath + "/"; string ImageFileLocation = AppUrl;
ImageFileLocation = ImageFileLocation.Substring(ImageFileLocation.LastIndexOf("\\")+1);
ImageFileLocation += DefaultImageFolder;
ImageFileLocation += "/";
string UploadFileName = "";
string UploadFileDestination = "";
UploadFileName = UploadFile.PostedFile.FileName;
UploadFileName = UploadFileName.Substring(UploadFileName.LastIndexOf("\\")+1);
string ImageFileExtention = UploadFileName.Substring(UploadFileName.LastIndexOf("."));
UploadFileDestination = HttpContext.Current.Request.PhysicalApplicationPath;
UploadFileDestination += DefaultImageFolder;
UploadFileDestination += "\\";
string NewFileName = DateTime.Now.Year.ToString()+DateTime.Now.Month.ToString()+DateTime.Now.Day.ToString()+DateTime.Now.Hour.ToString()+DateTime.Now.Minute.ToString()+DateTime.Now.Second.ToString();
UploadFile.PostedFile.SaveAs(UploadFileDestination + NewFileName + ImageFileExtention);
System.Drawing.Image image = System.Drawing.Image.FromFile(UploadFileDestination + NewFileName + ImageFileExtention);
Response.Write("<script>var arr=new Array();arr['filename']='"+ImageFileLocation+NewFileName + ImageFileExtention+"';arr['width']='"+image.Width+"';arr['height']='"+image.Height+"';window.parent.returnValue = arr;window.parent.close();<" + "/" + "script>");
}
}
private bool IsValidFileType(string FileName) {
string ext = FileName.Substring(FileName.LastIndexOf(".")+1,FileName.Length-FileName.LastIndexOf(".")-1);
for (int i=0; i<AcceptedFileTypes.Length; i++) {
if (ext == AcceptedFileTypes[i]) {
return true;
}
}
return false;
}
</script>
<asp:panel id="MainPage" runat="server" visible="false">
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<META HTTP-EQUIV="Expires" CONTENT="0">
<title>插入图片</title>
<style>body {
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
background: #ffffff;
width: 100%;
overflow:hidden;
border: 0;
}body,tr,td {
color: #000000;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10pt;
}div.imagespacer {
width: 120;
height: 126;
text-align: center;
float: left;
font: 10pt verdana;
margin: 5px;
overflow: hidden;
}
div.imageholder {
margin: 0px;
padding: 0px;
border: 1 solid #CCCCCC;
width: 100;
height: 100;
}div.titleholder {
font-family: ms sans serif, arial;
font-size: 8pt;
width: 100;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
} </style>
<script language="javascript">
lastDiv = null;
function divClick(theDiv,filename) {
if (lastDiv) {
lastDiv.style.border = "1 solid #CCCCCC";
}
lastDiv = theDiv;
theDiv.style.border = "2 solid #316AC5";
document.getElementById("FileToDelete").value = filename;}
function showimg(){
document.all.imgview.innerHTML="<img src='"+document.all.UploadFile.value+"'>";
}
function returnImage(imagename,width,height) {
var arr = new Array();
arr["filename"] = imagename;
arr["width"] = width;
arr["height"] = height;
window.parent.returnValue = arr;
window.parent.close();
}
</script>
</HEAD>
<body>
<table width=100% height=100% cellpadding=0 cellspacing=0 border=0><FORM encType="multipart/form-data" runat="server" ID="Form1"><tr><td>
<div id="galleryarea" style="width=100%; height:100%; overflow: auto;">
<asp:label id="gallerymessage" runat="server"></asp:label>
<asp:panel id="GalleryPanel" runat="server"></asp:panel>
<span id="imgview"></span>
</div>
</td></tr>
<asp:Panel id="UploadPanel" runat="server">
<tr><td height=16 style="padding-left:10px;border-top: 1 solid #999999; background-color:#99ccff;">
<table>
<tr>
<td valign=top><input id="UploadFile" type="file" name="UploadFile" onchange="showimg()" runat="server" style="width:300;"/></td>
<td valign=top><asp:button id="UploadImage" Text="上传" runat="server" onclick="UploadImage_OnClick" /></td>
</tr>
<tr>
<td colspan=3>
<asp:RegularExpressionValidator runat="server"
ControlToValidate="UploadFile"
id="FileValidator" display="dynamic"/>
<asp:literal id="ResultsMessage" runat="server" />
</td>
</tr></table>
<input type="hidden" id="RootImagesFolder" Value="images" runat="server" NAME="RootImagesFolder"/>
</td></tr>
</asp:panel>
</form>
</table>
</body>
</HTML>
</asp:panel>
<asp:panel id="iframePanel" runat="server" >
<html>
<head><title>插入图片</title></head>
<style>
body {
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
background: #ffffff;
overflow:hidden;
}
</style>
<body>
<iframe style="width:100%;height:100%;border:0;" border=0 frameborder=0 src="ftb.imagegallery.aspx?frame=1&<%=Request.QueryString%>"></iframe>
</body>
</html>
</asp:panel>