日期:2014-05-18  浏览次数:20428 次

在线等 ASP.NET 大文件上传 各位高手帮帮忙 我的分不多,但有一份感恩的心 急盼!
我用aspupload上传组件上传,已经在asp.net下运行通过,可是,发布到IIS上之后,上传文件,每次无法获取文件。
代码如下:
<!-- AspUpload .NET Code samples: ado_upload.aspx -->
<!-- Invoked by ado.aspx -->
<!-- Copyright (c) 2002 Persits Software, Inc. -->
<!-- http://www.persits.com -->

<%@ Page aspCompat="True" Debug="True" %>

<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Reflection" %>
<%@ Import Namespace="ASPUPLOADLib" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="Siwei.Webmap" %>
<%@ Import Namespace="System.IO" %>



<script runat="server" LANGUAGE="C#">

void Page_Load(Object Source, EventArgs E)
{

   
  ASPUPLOADLib.IUploadManager objUpload;
objUpload = new ASPUPLOADLib.UploadManager();

  string filepath = Server.MapPath("Upload/");
  DirectoryInfo dir = new DirectoryInfo(filepath);
  if (!dir.Exists)
  {
  dir.Create();
  }
  int Count = objUpload.Save(filepath, Missing.Value, Missing.Value);

  // int Count = objUpload.Save(@"c:\upload");

  ASPUPLOADLib.IUploadedFile objFile = objUpload.Files.Item("THEFILE");//THEFILE <INPUT TYPE=FILE NAME="THEFILE">在IIS上无法获取到里面的文件,问题就处在此处

if( objFile != null )
{
   

  System.IO.FileStream fs = null;
  System.IO.BinaryReader br = null;
  try
  {
  fs = new System.IO.FileStream(filepath + objFile.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
  }
  catch
  {

  }
  try
  {
  br = new System.IO.BinaryReader(fs);
  byte[] photo = br.ReadBytes((int)fs.Length);
  page.DataAccess.SaveBLOB("drawarrtblob", "drawing", "id='" + ID + "'", photo);

  }
  catch
  {

  }

  br.Close();
  fs.Close(); 
   
   
  Response.Write("<script>alert('上传成功')"+"<"+"/script>");
   
  //Response.Write("<input TYPE=\"button\" VALUE=\"返回\" ONCLICK=\"history.back(-1)\"CssClass=\"SubmitButton\" id=\"Button1\">");

}
else
{
txtResult.InnerHtml = "File not selected.";
}
}

</script>

<html>
<body>

<div id="txtResult" runat="server"/>

</body>
</html>



------解决方案--------------------
顶,好像得用第三方插件或者自己定义一个控件,CSDN上有人发布过这类控件
------解决方案--------------------
/// <summary>
/// 上传图片
/// </summary>
/// <param name="MyUpfile">上传控件</param>
/// <param name="newpath">服务器相对路经</param>
/// <returns>返回图片名称加后缀</returns>
public string Uploadfile(FileUpload MyUpfile, string newpath,string returnpath)
{
if (MyUpfile.FileName != "")
{
string pic = DateTime.Now.Mil