最后的50分,FreeTextBox的图片上传功能没有用。
我把改后的代码贴出来大家帮一下。
<%@ 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 = "Uploads";  // 默认的起始文件夹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>
我用过都是好用的,可突然间就不好用了,只能浏览图片,上传按纽就不好用了。

解决方案 »

  1.   

    我没有用过,我长期使用 ewebeditor,绝对不会出现问题
    下载地址如下:
    http://ewebeditor.webasp.net/download.asp
      

  2.   

    to hchxxzx(NET?摸到一点门槛) ,真的那么好用吗?我可以加你吗?我的qq是116651183。
      

  3.   

    ewebeditor asp 免费版我用过,感觉不错, ASP.NET 控件版没见过。我用的 FreeTextBox 3.0 没有见过源码,不知道楼主用的哪一版?还有源码。
      

  4.   

    FreeTextBox1.63的源码我有! 简体是文版, 很好用!·
      

  5.   

    hchxxzx推荐的ewebeditor不错,我也一直用。
      

  6.   

    http://www.percyboy.com/w/ftb/
    FreeTextBox 1.6.3 (中文版)
    可以传文件