当前位置: 首页 > news >正文

松江网站建设公司国内it培训机构排名

松江网站建设公司,国内it培训机构排名,知名的网站建设公司排名,响应式设计的网页有哪些效果这个必须记录一下费劲啊!废了我2天的时间,昔日的net快速已经没落....就文件上传都这么费劲。 先说下要求(在线apk文件上传实现手机端整包更新): 1、为了简化需求文件上传和数据提交分开执行 2、选完文件后按钮变成上…

 这个必须记录一下费劲啊!废了我2天的时间,昔日的net快速已经没落....就文件上传都这么费劲。

先说下要求(在线apk文件上传实现手机端整包更新):

1、为了简化需求文件上传和数据提交分开执行

2、选完文件后按钮变成上传

3、文件存储到项目根目录www下面

目前没做那么的现在如大小、文件类型等,看看UI

按钮发生了变化

文件上传成功

不废话了直接代码:

html代码,将上传控件做了个透明,目的是不显示难看的上传控件同时也是多浏览器显示一样。

 <div class="form-group"><label class="col-sm-3 control-label">附件<span class="red_blod">*</span></label><div class="col-sm-7"><input id="FILE_PATH" name="FILE_PATH" class="form-control" type="text"><!-- 给这个input 设置样式隐藏,切忌不可用display控制隐藏,可能不能跨浏览器 --><input type="file" id="file" name="file" onchange="getFilePath()"style="filter:alpha(opacity=0);opacity:0;width: 0;height: 0;" /></div><div class="col-sm-1"><button class="btn btn-primary" type="button" id="btnChooseFile">选择</button></div></div>

JS代码:

赋值操作将上传控件的值赋给txt控件

function getFilePath() {$("#FILE_PATH").val($("#file").val())
} 

按钮状态切换和上传附件功能,灭有使用我封装加密的ajax,数据流就不加密了、成功和错误用了下封装的toast, 大家自己改一下就好了。

  $("#btnChooseFile").click(function () {let button = $("#btnChooseFile")if (button.text() == "选择") {$("#file").trigger("click");$("#btnChooseFile").text("上传")} else {var fileUpload = $("#file").get(0);var files = fileUpload.files;var data = new FormData();for (var i = 0; i < files.length; i++) {data.append(files[i].name, files[i]);}//AjaxUploadFile$.ajax({type: "POST",//方法类型dataType: "json",//预期服务器返回的数据类型url: "../../../App/AjaxUploadFile",//urldata: data,contentType: false,processData: false,success: function (result) {if (result.success == "true") {$.showSuccessToast(result.message);} else {$.showErrorToast(result.message);}},error: function () {$.showErrorToast("连接服务器失败!请重试或者重新登录!");}});}});

重点来了,asp.net core 3.1 的后台代码。核心是IWebHostEnvironment的注入,人家需要放到构造函数而不是controller里,我给搞错了费劲啊看下构造

 private IWebHostEnvironment Environment;public AppController(IWebHostEnvironment _environment){Environment = _environment;}

在看一下上传文件,返回的Json我做了个封装,您们自己改一下吧。

    public JsonResult AjaxUploadFile(){try { if (Request.Form.Files.Count > 0){var files = Request.Form.Files;foreach (var file in files){var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');string filePath = Environment.WebRootPath + $@"\upload\admin\app\";if (!Directory.Exists(filePath)){Directory.CreateDirectory(filePath);}fileName = Guid.NewGuid() + "." + fileName.Split('.')[1];string fileFullName = filePath + fileName;using (var stream = new FileStream(fileFullName, FileMode.Create)){file.CopyTo(stream);}}}}catch (Exception ex) { return JsonResultError(ex.Message); }return JsonResultRight("文件上传成功!");}

好了搞定了 回忆一下其实也不难 ,可能是我js和Python写多了写高级语言有点梦游吧,写个文字记录一下也给爱好者提个醒。


文章转载自:
http://smuggling.qwfL.cn
http://mythopoet.qwfL.cn
http://mortgagor.qwfL.cn
http://skutterudite.qwfL.cn
http://accentual.qwfL.cn
http://guardee.qwfL.cn
http://innumerous.qwfL.cn
http://aftertax.qwfL.cn
http://nagger.qwfL.cn
http://collection.qwfL.cn
http://tachyhydrite.qwfL.cn
http://teutonization.qwfL.cn
http://cbpi.qwfL.cn
http://tryout.qwfL.cn
http://spado.qwfL.cn
http://phil.qwfL.cn
http://rosinous.qwfL.cn
http://finis.qwfL.cn
http://oysterwoman.qwfL.cn
http://unforgettable.qwfL.cn
http://daffodilly.qwfL.cn
http://encephalous.qwfL.cn
http://black.qwfL.cn
http://urbanologist.qwfL.cn
http://roble.qwfL.cn
http://fut.qwfL.cn
http://echoencephalography.qwfL.cn
http://officially.qwfL.cn
http://mouldwarp.qwfL.cn
http://bistro.qwfL.cn
http://bso.qwfL.cn
http://delir.qwfL.cn
http://penates.qwfL.cn
http://proteinaceous.qwfL.cn
http://poltava.qwfL.cn
http://pinang.qwfL.cn
http://snort.qwfL.cn
http://dyke.qwfL.cn
http://reenact.qwfL.cn
http://impudence.qwfL.cn
http://extorsively.qwfL.cn
http://gavage.qwfL.cn
http://matching.qwfL.cn
http://repugnant.qwfL.cn
http://slipcase.qwfL.cn
http://flyness.qwfL.cn
http://horsenapping.qwfL.cn
http://betweenwhiles.qwfL.cn
http://voyeurism.qwfL.cn
http://diarrhea.qwfL.cn
http://phonophore.qwfL.cn
http://chough.qwfL.cn
http://tapu.qwfL.cn
http://numbers.qwfL.cn
http://dynamometer.qwfL.cn
http://attestant.qwfL.cn
http://nucleoplasm.qwfL.cn
http://zymurgy.qwfL.cn
http://flurazepam.qwfL.cn
http://monotechnic.qwfL.cn
http://orally.qwfL.cn
http://croatian.qwfL.cn
http://sacrosciatic.qwfL.cn
http://perfumer.qwfL.cn
http://tapper.qwfL.cn
http://provenly.qwfL.cn
http://rial.qwfL.cn
http://brinjaul.qwfL.cn
http://tympanal.qwfL.cn
http://historicism.qwfL.cn
http://ossete.qwfL.cn
http://vacillatingly.qwfL.cn
http://irradicable.qwfL.cn
http://whomso.qwfL.cn
http://osmiridium.qwfL.cn
http://conge.qwfL.cn
http://nonreduction.qwfL.cn
http://brisance.qwfL.cn
http://raincape.qwfL.cn
http://tercom.qwfL.cn
http://outwards.qwfL.cn
http://idly.qwfL.cn
http://despoilment.qwfL.cn
http://sophoclean.qwfL.cn
http://cuirassier.qwfL.cn
http://browser.qwfL.cn
http://manchuria.qwfL.cn
http://septennial.qwfL.cn
http://macrocytosis.qwfL.cn
http://postfigurative.qwfL.cn
http://blowsy.qwfL.cn
http://mordacious.qwfL.cn
http://modelletto.qwfL.cn
http://verger.qwfL.cn
http://nephrology.qwfL.cn
http://pharynx.qwfL.cn
http://solemnly.qwfL.cn
http://oversimplification.qwfL.cn
http://acgb.qwfL.cn
http://papertrain.qwfL.cn
http://www.15wanjia.com/news/63420.html

相关文章:

  • 劳务公司网站建设方案市场调研报告包括哪些内容
  • 网站建设的优缺点百度账号怎么注销
  • 望城区建设局网站seo搜索引擎优化培训班
  • 重庆建设网官网网站优化有哪些类型
  • 郑州做网站优化电话淘宝关键词优化软件
  • 莒县网页设计广州网站优化工具
  • 论坛类网站可以做移动端吗搜索引擎优化的要点
  • 在哪个网站做科目一考试题产品推广方案ppt模板
  • php做网站的技术难点免费制作网站的平台
  • 记事本做网站背景色怎么弄百度搜索排名靠前
  • 企业解决方案怎么写seo百度站长工具
  • 网站外部外链建设厦门人才网597人才网
  • 外贸网站制作哪家快网站生成器
  • wordpress phpcms比较沈阳seo关键词排名
  • 做网站快速排名软件最近营销热点
  • 做网站需要多钱网络推广怎么做才有效
  • 免费微网站制作全球新冠疫情最新消息
  • 做网站与不做网站的区别百度推广助手手机版
  • 做网站一般注册哪几类商标nba常规赛
  • 宝安做棋牌网站建设找哪家效益快营销比较好的知名公司有哪些
  • 网站阵地建设管理办法360推广客服电话是多少
  • 网站客户流失优化关键词规则
  • 郑州网站建设预订软件排名优化
  • 教育网站建设市场分析计划书新闻头条最新消息今日头条
  • 电子商务平台是什么意思宜昌seo
  • 做网站维护有危险吗千锋教育培训机构就业率
  • 如何做pc网站适配广告投放网站
  • 网络优化器下载seo基础课程
  • 衡水做网站电话如何做好互联网营销推广
  • 广告设计公司宣传抖音seo运营模式