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

杭州盘石做网站专业吗做兼职什么网站比较好

杭州盘石做网站专业吗,做兼职什么网站比较好,网页设计代码显示时间,如何建立自己的电商平台因项目需求#xff0c;需要一个上传图片并显示的功能#xff0c;类似于上传头像并显示出来。查阅了网上资料#xff0c;写了个Demo#xff0c;希望能帮助到更多的人。此Demo基于ASP.NET MVC实现。 选择图片#xff1a; 点击按钮进行上传#xff1a; 一、先在项目中新建一… 因项目需求需要一个上传图片并显示的功能类似于上传头像并显示出来。查阅了网上资料写了个Demo希望能帮助到更多的人。此Demo基于ASP.NET MVC实现。 选择图片 点击按钮进行上传  一、先在项目中新建一个文件夹用于存放图片  二、View页面代码  {Layout null; }!DOCTYPE html html headmeta http-equivContent-Type contenttext/html; charsetutf-8 /meta charsetutf-8 /meta nameviewport contentwidthdevice-width, initial-scale1.0script src~/Scripts/jquery-3.3.1.min.js/scriptscript src~/Scripts/jquery.unobtrusive-ajax.min.js/script /head bodyusing (Ajax.BeginForm(, null, new AjaxOptions() { OnSuccess PostSuc, OnFailure PostFail, HttpMethod Post }, new { enctype multipart/form-data, id FormBaseData })){input typehidden nameMouldId idMouldId value9527 /input typefile namefile1 /input typebutton valuesubmit idbtnSubmit /img src width300 height300 display:inline; alt图片预览 idmypicture /} /body /htmlscript typetext/javascript$(document).ready(function () {$(#btnSubmit).bind(click, function () { Query(); });})function Query() {$(#FormBaseData).attr(data-ajax-success, OnQuerySuccess(data));$(#FormBaseData).attr(data-ajax-failure, OnQueryFail());$(#FormBaseData).attr(action, /home/UploadImg);$(#FormBaseData).submit();}function OnQuerySuccess(data) {$(#mypicture).attr({ src: data });}function OnQueryFail() {alert(发生错误!);} /script 三、Controller端代码  using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc;namespace WebApplication1.Controllers {public class HomeController : Controller{public ActionResult Index(){return View();}[HttpPost]public ActionResult UploadImg(long MouldId){string msg string.Empty;if (Request.Files.Count 0){HttpPostedFileBase file Request.Files[file1];if (file.ContentLength 5 * 1024 * 1024){string fileType System.IO.Path.GetExtension(file.FileName);//获取文件类型if (!System.IO.Directory.Exists(Server.MapPath(~/Pictures/))){System.IO.Directory.CreateDirectory(Server.MapPath(~/Pictures/));}string filePath Server.MapPath(~/Pictures/);//保存文件的路径if (fileType ! null){fileType fileType.ToLower();//将文件类型转化成小写if ((.gif)|(.jpg)|(.bmp)|(.jpeg)|(.png).Contains(fileType)){file.SaveAs(filePath file.FileName);string str Pictures/ file.FileName;msg str;}else{msg 只支持图片格式;}}}else{msg 图片大小不能超过5M;}}else{msg 上传图片不能为空;}return Content(msg);}} }参考https://blog.csdn.net/weixin_44540201/article/details/89630530
http://www.pierceye.com/news/16134/

相关文章:

  • 做a小视频网站网络公司注册资金最低标准
  • 网站建设的工期拖延如何解决社交电商是做什么的
  • 百度推广与做网站推广的区别网站开发项目源码
  • 网站地图做法做如何增加网站反链
  • 学校网站管理方案网站后台制作这么做
  • 网站信息登记表塑胶制品东莞网站建设
  • 四平网站建设哪家效果好设计在线官网作品欣赏
  • 阿里云服务器 个人网站网站开发技术实验教程
  • 免费建简单网站云主机和云服务器有什么区别
  • 公司建设一个网站平台网站建设预算表
  • 重庆建设机电网站php免费开源crm系统
  • 中国宣布入境最新消息2023怎么给一个网站做seo
  • 网站手机模板源码网络工程师可以从事什么工作
  • 网站建设线框图广州建设网站制作
  • 中国设计师网站大同市住房城乡建设网站
  • 毕业设计做 做交易网站网页视频下载用什么软件最好
  • 南京网站建设哪家好杭州做网站推广公司推荐
  • 网站建设分工案例搜狗提交入口网址
  • 企业网站建设费用计入什么科目帝国 cms 网站关键字
  • 网站的三大标签西双版纳傣族自治州房价
  • php网站建设教程域名备案需要有网站吗
  • 海北高端网站建设公司wordpress慢 google
  • 北京门户网站网址天元建设集团有限公司 李增启
  • php 网站开发好域名做网站
  • 动力 网站建设seo怎么优化关键词排名培训
  • 网站建设列表网百度登录首页
  • 企业网站开发语言网站文章页的排名怎么做
  • 工信部备案网站医疗网站整站优化思路
  • 人事处网站开发文献综述软件公司注册条件
  • 攀枝花网站开发怎么做学校子网站