zoukankan      html  css  js  c++  java
  • c#中文件上传(1)

                    
    这个是.aspx页面中用来上传文件的接口,适用于App接口

    int
    maxlength = 1024 * 1024 * 3;//3M picPath = Server.MapPath("........."); HttpFileCollection postfile = Context.Request.Files; for (int i = 0; i < postfile.Count; i++) { HttpPostedFile file = postfile[i]; if (!CheckType(GetExtension(file.FileName).Substring(1))) { r.success = false; r.message = "文件类型不正确,上传失败!"; } if (file.ContentLength > maxlength) { r.success = false; r.message = "上传文件的大小超过了3MB的最大容量!请压缩后再上传!"; } string strNewPath = DateTime.Now.ToShortDateString().Replace("-", "") + DateTime.Now.ToLongTimeString().Replace(":", "") + DateTime.Now.Millisecond + GetExtension(file.FileName); file.SaveAs(picPath +"/"+ strNewPath); strNewPath = strNewPath.Replace("\", "/"); urlPath = picServer + strNewPath; originalname = GetOriginalName(file.FileName); if (originalname == "") { originalname = file.FileName; } string newName = GetOriginalName1(strNewPath); file.SaveAs(Server.MapPath(".") + "/" + Path.GetFileName(file.FileName)); }
  • 相关阅读:
    word 操作技巧
    有朝一日
    菜狗日记2021.7.10
    记一次JSON.toJSONString()踩坑
    菜狗日记2020.11.13
    菜狗日记2020.11.6
    菜狗日记2020.11.03
    菜狗日记2020.10.29
    菜狗日记2020.10.17
    菜狗日记2020.10.11
  • 原文地址:https://www.cnblogs.com/ly77461/p/5772785.html
Copyright © 2011-2022 走看看