用微软的控件  如 
File Filed  使他runat=server  
用其控件的 saveas方法

解决方案 »

  1.   

    用HtmlInputFile ,结合其PostedFile.SaveAs方法就可以了
    搜索一下就能找到很多例子
      

  2.   

    到老孟的网站去看看吧
    http://dotnet.aspx.cc/ShowDetail.aspx?id=58EA3515-36F2-4FD9-AC89-EAF49F59816C
      

  3.   

    private void ibtn_change_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
    string path=this.Server.MapPath("../"+Session["diqu"].ToString()+"/"+Session["shixian"].ToString()+"/"+Session["username"].ToString()+"/image");
    string filename="";
    long filesize;
    if(this.ff_tp.PostedFile.FileName.Trim()=="")
    {
    DataSet dst=new DataSet();
    //ld.update((string)Session["czming"],this.txt_shuoming.Text,this.txt_neirong.Text,this.drop_shunxu.SelectedItem.Text,id,this.txt_shuoming2.Text);
    gh.insert(Session["czming"].ToString(),this.txt_neirong.Text,this.txt_shuoming.Text,filename);
    this.Response.Redirect("adminguihua.aspx");
    }
    else
    {
    try
    {
    filename=this.ff_tp.PostedFile.FileName.ToString();
    string[] type=filename.Split('.');
    string filetype = type[type.Length - 1];
    filesize = this.ff_tp.PostedFile.ContentLength;
    string fileName = System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() + System.DateTime.Now.Hour.ToString() + System.DateTime.Now.Minute.ToString() +System.DateTime.Now.Second.ToString();
    filename = fileName+"." + filetype;
    HttpFileCollection MyFileColl = HttpContext.Current.Request.Files; 
    HttpPostedFile MyPostedFile = MyFileColl[0]; 
    if (filesize> 204800)
    {
    this.lbl_error.Text="上传附件大小不能超过2MB!";
    }
    else
    {
    if(filetype == "gif" || filetype == "jpg")
    {

    DataSet dst=new DataSet();
    this.GetThumbNail(filename,130,100,this.ff_tp.PostedFile.ContentType.ToString(),false,MyPostedFile.InputStream);
    gh.insert(Session["czming"].ToString(),this.txt_neirong.Text,this.txt_shuoming.Text,filename);
    this.Response.Redirect("adminguihua.aspx");
    this.ff_tp.Value="";
    }
    else
    this.lbl_error.Text="上传的附件只能是GIF、JPG格式的文件!";
    }
    }
    catch(Exception er)
    {
    this.lbl_error.Text=er.Message;
    }
    }
      

  4.   

    用System.Web.WebClient类的UploadFile方法,以下例子来自MSDN2003:示例
    [Visual Basic, C#, C++] 注意   此示例显示如何使用 UploadFile 的一个重载版本。有关其他可用示例,请参阅单独的重载主题。[C#] 
    Console.Write("\nPlease enter the URL to post data to : ");
    String uriString = Console.ReadLine();// Create a new WebClient instance.
    WebClient myWebClient = new WebClient();Console.WriteLine("\nPlease enter the fully qualified path of the file to be uploaded to the URL");
    string fileName = Console.ReadLine();Console.WriteLine("Uploading {0} to {1} ...",fileName,uriString);                        
    // Upload the file to the URL using the HTTP 1.0 POST.
    byte[] responseArray = myWebClient.UploadFile(uriString,"POST",fileName);// Decode and display the response.
    Console.WriteLine("\nResponse Received.The contents of the file uploaded are: \n{0}",Encoding.ASCII.GetString(responseArray));
      

  5.   

    private System.Drawing.Imaging.ImageFormat GetImageType(object strContentType) 

    if ((strContentType.ToString().ToLower()) == "image/pjpeg") 

    return System.Drawing.Imaging.ImageFormat.Jpeg; 

    else if ((strContentType.ToString().ToLower()) == "image/gif") 

    return System.Drawing.Imaging.ImageFormat.Gif; 

    else if ((strContentType.ToString().ToLower()) == "image/bmp") 

    return System.Drawing.Imaging.ImageFormat.Bmp; 

    else if ((strContentType.ToString().ToLower()) == "image/tiff") 

    return System.Drawing.Imaging.ImageFormat.Tiff; 

    else if ((strContentType.ToString().ToLower()) == "image/x-icon") 

    return System.Drawing.Imaging.ImageFormat.Icon; 

    else if ((strContentType.ToString().ToLower()) == "image/x-png") 

    return System.Drawing.Imaging.ImageFormat.Png; 

    else if ((strContentType.ToString().ToLower()) == "image/x-emf") 

    return System.Drawing.Imaging.ImageFormat.Emf; 

    else if ((strContentType.ToString().ToLower()) == "image/x-exif") 

    return System.Drawing.Imaging.ImageFormat.Exif; 

    else if ((strContentType.ToString().ToLower()) == "image/x-wmf") 

    return System.Drawing.Imaging.ImageFormat.Wmf; 

    else 

    return System.Drawing.Imaging.ImageFormat.MemoryBmp; 

    }
      

  6.   

    private void GetThumbNail(string strFileName, int iWidth, int iheight, 
    string strContentType, bool blnGetFromFile, System.IO.Stream ImgStream) 

    System.Drawing.Image oImg;

    if (blnGetFromFile) 

    oImg = System.Drawing.Image.FromFile(strFileName); 

    else 

    oImg = System.Drawing.Image.FromStream(ImgStream); 

    oImg = oImg.GetThumbnailImage(iWidth, iheight, null, IntPtr.Zero); 
    string strGuid = System.Guid.NewGuid().ToString().ToUpper(); 
    string strFileExt = strFileName.Substring(strFileName.LastIndexOf(".")); 
    Response.ContentType = strContentType; 
    // MemoryStream MemStream = new MemoryStream(); 
    string path=this.Server.MapPath("../"+Session["diqu"].ToString()+"/"+Session["shixian"].ToString()+"/"+Session["username"].ToString()+"/image/");
    oImg.Save(path+strFileName);
    // oImg.Save(MemStream, GetImageType(strContentType)); 
    // MemStream.WriteTo(Response.OutputStream); 
    }
      

  7.   

    ASP.NET File Uploading
    http://www.ondotnet.com/pub/a/dotnet/2002/04/01/asp.html
    http://www.codeproject.com/aspnet/fileupload.asp
      

  8.   

    asp.net自带的io类就可以实现
    ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfSystemIO.htm
    但是,如果是网站的空间的话,那还涉及到权限问题,要与网站的管理员商量