<form id="form1" action="Default.aspx" enctype="mutltipart/form-data" method="post" >
    <div>
        <table width="400" border="1">
            <tr>
                <td colspan="2" align="center">
                    添加友情链接
                </td>
            </tr>
            <tr>
                <td>
                    公司名字:
                </td>
                <td>
                  <input type="text" id="txtName" name="txtName"/>
                                   </td>
            </tr>
            <tr>
                <td>
                    网站路径:
                </td>
                <td>
                <input type="text" id="txtPath" name="txtPath" value="http://"/>
                
                </td>
            </tr>
            <tr>
                <td>
                    上传图片:
                </td>
                <td>
                <input type="file" id="file1" name="file1" />
                                  </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                   
                    <input type="submit" value="确定" />
                    
                </td>
            </tr>
        </table>
</body>
</from>
Default.aspx.cs 页面不知道怎么写了 
求高手解决 给高分

解决方案 »

  1.   

    http://hi.baidu.com/21tian/blog/item/ca9e09d1849b67d9572c84dc.html
    参考
      

  2.   

    protected void btnUpload_Click(object sender, EventArgs e) 
        { 
            if(fileUpload.HasFile) 
            { 
                string savePath = Server.MapPath("~/upload/"); 
                if (!System.IO.Directory.Exists(savePath)) 
                { 
                    System.IO.Directory.CreateDirectory(savePath); 
                } 
                savePath = savePath + "\\" + fileUpload.FileName; 
                fileUpload.SaveAs(savePath);//保存文件 
            } 
        } 
      

  3.   

    function AddFile()
    {
    var strFile="<input name=\"upload_A\" type='file' class='inputText' style='WIDTH:350px;'/><br/>";
    document.getElementById("td_uploadFile").insertAdjacentHTML("beforeEnd",strFile);
    }
    <td id="td_uploadFile" align="center">
      <input id="upload_A" name="upload_A" type="file" class="inputText"
      style="width: 350px; display:none;" runat="server" />
      </td> HttpFileCollection Files = HttpContext.Current.Request.Files;
      for (int i = 0; i < Files.Count; i++)
      {  HttpPostedFile PostedFile = Files[i];
      if (PostedFile.ContentLength > 0)
      {
      string FileName = PostedFile.FileName;
      string AttachExt = FileName.Substring(FileName.LastIndexOf(".") + 1);
      int TotalSize = PostedFile.ContentLength;
      }
      }
      

  4.   

    4楼的帅哥 好像也是使用了服务器控件吧 我想要的效果是不要服务器控件HTML代码 贴出来了。
      

  5.   

    就没有哪位大哥 在我给的HTML代码的基础想写么 谢谢了。
      

  6.   

    没有runat=server   cs后台是啥也获取不了的!!  这是.net 最最基本的东西你完全是asp写法  后面加个x 而已  asp的无组件上传  想用到.net 上  , 完全根本不是那回事啊
      

  7.   


    string picture = System.Configuration.ConfigurationManager.AppSettings["Picture"].ToString();
                if (this.File1.FileName != "")
                {
                    if (Convert.ToString(Session["Pic1"]) != "")
                    {
                        string path1 = Server.MapPath(Convert.ToString(Session["Pic1"]));
                        File.Delete(path1);
                    }
                    divview1.Visible = true;
                    int MaxLength1 = 1024 * 1024;
                    string roodom = DateTime.Now.ToString("yyMMddHHmmss");
                    string name1 = roodom + this.File1.FileName;
                    string type1 = name1.Substring(name1.LastIndexOf(".") + 1).ToLower();
                    if (this.File1.PostedFile.ContentLength > MaxLength1)
                    {
                        Show("上传文件的大小超过了1MB的最大容量!请压缩后再上传!!");
                        return;
                    }
                    if (type1 == "jpg" || type1 == "bmp" || type1 == "gif" || type1 == "png" || type1 == "jpeg" || type1 == "wmf")
                    {
                        string filepath0 = Server.MapPath("Pic/" + name1);
                        string filepath1 = "Pic/" + name1;
                        model.PHOTOURL = filepath1;
                        this.File1.SaveAs(filepath0);                }
                    else
                    {
                        Show("你的照片文件格式不符合要求!");
                        return;
                    }
                }
                else if (Session["Pic1"] != null && Convert.ToString(Session["Pic1"]) != "")
                {
                    model.PHOTOURL = Convert.ToString(Session["Pic1"]);
                }
                else
                {
                    model.PHOTOURL = picture;
                }