首页 > 编程知识 正文

layui图片上传带参数如何上传,vue上传图片到服务器

时间:2023-05-05 08:22:17 阅读:37013 作者:3792

llayui的上传图像和C# asmx文件接收图像是本地varuploadinst=upload.render (elem : ) #savetest(/绑定元素,URL : (/web apptest.aptest ) ) ) ayui data : { ' type ' : ' update ',' text _ item ' : function ({ returnidexpage } ), ' plate_id'3360plate_} upload(if ) RES.msg=='ok ' ) layer.open ) ) content: )修改完成(,icon: 1 1,anim }; ); },错误: function (() /要求异常回调) ); 后台C#

[ web method (描述='上传图像',EnableSession=true ) { try { string pathf=' '; //用户特定的idstringuser=session [ ' userid ' ].tostring (; //取出类型string type=httpcontext.current.request [ ' type ' ].tostring (; //板idstringplate _ id=httpcontext.current.request [ ' plate _ id ' ].tostring (; string TEXT_ITEM=' '; //用于删除的itemif(type=='update ' ) /修改的任何照片text _ item=httpcontext.current.request (' text _ item ' ).tostritem=null(//获取流长度的文档intls=httpcontext.current.request.files [ ' file ' ].contentlength; //随机名称stringimgnamef=system.guid.new guid ().ToString ); //数组byte[] bufferf=new byte[ls]; //接收名称为file的文件流streamsf=httpcontext.current.request.files [ ' file ' ].inputstream; //读取流是保存在数组中的SF.read(bufferf,0,bufferf.Length ); SF.seek(0,SeekOrigin.Begin ); pathf='/uploadfile/' user '/' datetime.now.tostring (yyyymmdd ); if (! 目录. exists (httpcontext.current.server.mappath (pathf ) )//不带目录的新system.io.directory.createdidiate using (filestream fs=new filestream (httpcontext.current.server.mappath (pathf ),FileMode.Create,file access.ww }//数据库stringstr=httpcontext.current.request.URL.absolute uri; //获取项目路径//获取此web上的项目路径并剪切第三个/即端口后面的,以获取数据库intindex=str.indexof('/',7 ); str=str.substring(0,Index ); //实路径string src=str pathf; //新获取当前此ITEM的if (type==' add ' (string SQL=string.format ) select text _ itemfromvx _ img _ textwhereppx ) IF (数据!=null data.rows.count=0((text _ item=) data.rows.count1).ToString ); }intRES=bll.getLV(src,user,TYPE,PLATE_ID,TEXT_ITEM ); if(RES!=1) { Context.Response.Write (“异常”); } string Json='{'code': 1,'msg': 'ok', ' data' : {' src' 33652365365292; context.response.write(JSON; }catch(exceptione ) context.response.content type=' application/JSON '; string Json='{'code': 1,'msg': '' e.Message '', ' data' 3360 {' src} }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。