uot;NewFile"><br>
<input type="button" value="Send it to the Server" onclick="SendFile();">
</form>
</td>
<td style="WIDTH: 16px"> </td>
<td vAlign="top" width="100%">
Uploaded File URL:<br>
<INPUT id="txtUrl" style="WIDTH: 100%" readonly type="text">
</td>
</tr>
</table>
<br>
Post URL: <span id="eURL"> </span>
</td>
</tr>
<tr>
<td height="100%">
<iframe name="UploadWindow" width="100%" height="100%"></iframe>
</td>
</tr>
</table>
</body>
</html>
upload.aspx的内容:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Upload.aspx.cs" Inherits="Upload"%>
下面是后台代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.IO;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Collections.Specialized;
public partial class Upload : System.Web.UI.Page
{
public void SendResults(int errorNumber, string fileUrl, string fileName, string customMsg)
{
StringBuilder text = new StringBuilder();
text.Append("<script type=\"text/javascript\">");
text.Append("window.parent.OnUploadCompleted(" + errorNumber + ",\"" + fileUrl.Replace("\"", "\\\"") + "\",\"" + fileName.Replace("\"", "\\\"") + "\",\"" + customMsg.Replace("\"", "\\\"") + "\") ;\n");
text.Append(" </script>");
Response.Write(text.ToString());
Response.End();
}
public void GetConfig(string type, out string[] allowedExt, out string[] denyedExt,out string savePath,out long maxSize)
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath(@".\Config.xml"));
XmlElement root=doc.DocumentElement;
XmlNodeList imageNodelist=root.GetElementsByTagName(type);
allowedExt = imageNodelist[0].FirstChild.InnerText.Trim().Split('|');
denyedExt = imageNodelist[0].LastChild.InnerText.Trim().Split('|');
savePath = root.GetElementsByTagName("userPath").Item(0).InnerText.Trim();
try
{
maxSize = Convert.ToInt64(root.GetElementsByTagName("maxSize").Item(0).InnerText.Trim());
}
catch { maxSize = 10*1024; }
}
protected void Page_Load(object sender, EventArgs e)
{