在asp.net中我想把客户端例如C:\1.jpg上传到服务器固定文件夹(loadimg)谁能帮忙谢谢!
不用"<input type=file>"

解决方案 »

  1.   

    不用"<input type=file>"那你只能用第三方的上传组件了,自己下一个吧
      

  2.   

    aspx code:
      <asp:FileUpload ID="fufile" runat="server" />
            <asp:Button ID="btnupfile" runat="server" OnClick="btnupfile_Click" Text="UPLOAD" />
            <asp:Label ID="lbmsg" runat="server" Text="Label"></asp:Label>cs code:
      protected void btnupfile_Click(object sender, EventArgs e)
            {
                bool fileOk = false;
                string path = Server.MapPath("~/uploadImages/");
                if (fufile.HasFile)
                {
                    string fileExtension = System.IO.Path.GetExtension(fufile.FileName).ToLower();
                    string[] allowExtentsion = { ".gif", ".jpg" };
                    for (int i= 0;i < allowExtentsion.Length;i++)
                    {
                        if (fileExtension == allowExtentsion[i])
                        {
                            fileOk = true;
                        }
                    }
                
                }
                if (fileOk)
                {
                    try
                    {
                        fufile.PostedFile.SaveAs(path + fufile.FileName);
                        lbmsg.Text = "file UPLOADED!";
                    }catch(Exception EX)
                    {
                        lbmsg.Text="file could not be uploaded";
                    }
                
                }else            {
                    lbmsg.Text="文件类型不对";
                }
            }
      

  3.   

    为啥不用inputfile?有啥不好吗?