社区
Web Services
帖子详情
通过Web Service如何上传一个文件啊?
Soft21
2002-11-22 04:37:22
我想用Dot Net 写一个Web Service,让调用者给我上传一个文件。
请问我的Web Service该如何实现?
...全文
92
1
打赏
收藏
通过Web Service如何上传一个文件啊?
我想用Dot Net 写一个Web Service,让调用者给我上传一个文件。 请问我的Web Service该如何实现?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
1 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
wl0802
2002-11-23
打赏
举报
回复
在客户端(winform/asp.net)将文件化为byte[]
调用webservice的upload(byte[] file)方法,
将byte[]再组合成文件
[WebMethod]
public void Upload_file(Files file,byte[] filebyte)//上传文件
{
try
{
file.upload_time=DateTime.Now.ToString();
SelectCommand.CommandText="insert into DOWNLOAD_FILES(type,upload_time,fsize,clicktimes,discription,ownerid,property,filename) values('"+file.type+"','"+file.upload_time+"',"+file.fsize+","+file.clicktimes+",'"+file.discription+"',"+file.ownerID+",'"+file.property+"','"+file.filename+"')";
SelectCommand.Connection=Connect;
Connect.Open();
SelectCommand.ExecuteNonQuery();
SelectCommand.CommandText="select MAX(id) from DOWNLOAD_FILES";
SelectCommand.Connection=Connect;
int id=(int)(SelectCommand.ExecuteScalar());
FileStream s=new FileStream("C:\\Inetpub\\wwwroot\\files\\"+id,FileMode.Create);
s.Write(filebyte,0,filebyte.Length);
s.Close();
Connect.Close();
}
catch(Exception Upload_file_ex)
{
throw Upload_file_ex;
}
}
ASP.Net调用webservice:
private void Button1_Click(object sender, System.EventArgs e)
{
if(uplTheFile.PostedFile.ContentLength==0)Response.Write("请选择文件!");
else
{
Stream sfile=uplTheFile.PostedFile.InputStream;
byte[] filebyte=new byte[uplTheFile.PostedFile.ContentLength];
sfile.Read(filebyte,0,uplTheFile.PostedFile.ContentLength);
MICService.Files ff=new MICService.Files();
ff.fsize=uplTheFile.PostedFile.ContentLength;
ff.clicktimes=0;
ff.ownerID=Convert.ToInt32(Session["id"]);
ff.discription=dis.Text;
ff.type=type.SelectedItem.Value;
ff.property =property.SelectedItem.Value;
string [] split=(uplTheFile.PostedFile.FileName.ToString()).Split(new char[]{'\\'}) ;
ff.filename=split[split.Length-1];
ss.Upload_file(ff,filebyte);
Response.Redirect("netdisk.aspx");
}
}
给分!给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分给分
基于
Web
的酒店客房管理系统的设计与实现+论文+开题
管理员模块功能分析 对于管理员而言,
一个
好的管理系统总是能让酒店的管理工作事半功倍[7]。管理员 能够通过这个系统对自己的酒店情况一目了然,应该包括客户留言模块、客房管理模 块、订房信息管理模块、入住...
什么是
web
service
?
Web
Service
就是
一个
网络组件(
一个
可以通过网络访问的程序)。 它有
一个
或多个端口(Port),这些端口用于接收客户端的请求,并返回响应 请求和响应的 都是一种基于XML的消息。 不过这种消息遵循特定的格式...
什么是
Web
?
Web
Service
、
Web
API傻傻分不清楚?
分享一篇我在edx课程中看到的一篇英文文章,这篇文章详细阐述了
Web
、
Web
Server的含义,然后进一步介绍什么是
Web
API、
Web
Server、SOAP以及RESTFUL
Web
API的一些基础概念。本文根据个人的理解对原文进行了翻译,...
Web
Service
学习笔记
Web
Service
概述
Web
Service
的定义 W3C组织对其的定义如下,它是
一个
软件系统,为了支持跨网络的机器间相互操作交互而设计。
Web
Service
服务通常被定义为一组模块化的API,它们可以通过网络进行调用,来执行远程...
Web
Service
漏洞挖掘
Web
Service
是
一个
平台独立的,低耦合的,自包含的、基于可编程的
web
的应用程序,可使用开放的XML(标准通用标记语言下的
一个
子集)标准来描述、发布、发现、协调和配置这些应用程序,用于开发分布式的交互操作的...
Web Services
12,162
社区成员
16,328
社区内容
发帖
与我相关
我的任务
Web Services
.NET技术 Web Services
复制链接
扫一扫
分享
社区描述
.NET技术 Web Services
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章