zoukankan      html  css  js  c++  java
  • 文件上传(FileUpload控件)

    asp.net 文件上传,大文件上传。

     

        新建一个asp。net页面,在工具栏里拖入 FileUpload 上传控件.一个按钮 Button  !    !     !

        进入Button事件 //-------------------------------------------------------------------------   

                        string path = FileUpload1.PostedFile.FileName;              //获取上传文件的路径
                        string Name = path.Substring(path.LastIndexOf("\") + 1);   //获取文件名 
                        string Size = Convert.ToString(FileUpload1.PostedFile.ContentLength);      //获取文件大小
                        string Extend = path.Substring(path.LastIndexOf(".") + 1);  //获取文件扩展名
                        string Type = FileUpload1.PostedFile.ContentType;           //获取文件类型
                        string serverPath = Server.MapPath(@"新建一个文件,文件名") + Name;    //保存服务器的路径
                        FileUpload1.PostedFile.SaveAs(serverPath);                  //确定上传

        这样就可以上传文件到指定的文件里了。

        但是以上文件上传大小指定4MB,如果要上传更大的文件可以到 Web.config 配置文件里添加上一条语句:

                         //------------------------------加入配置-------------------------------------------------
                             <system.web>
                                  <httpRuntime executionTimeout="3600" maxRequestLength="1048576"/>
                                    </system.web>

        这样就可以上传大的文件到服务器上了。

  • 相关阅读:
    sqlserver2008r2 连接服务器报错64
    java web---HTTP略讲
    Web测试中定位bug方法
    Java1.8API大类
    如何查看windows电脑信息(win10)
    debain系统安装open-vm-tools
    windowns电脑环境配置
    配置了环境变量,adb还是不能用
    已经配了环境变量,但是执行命令却打开了应用商店
    cpython,jpython,ironpython,micropython,etc的区别
  • 原文地址:https://www.cnblogs.com/lxf1117/p/4153838.html
Copyright © 2011-2022 走看看