ASP/ASP.NET/VB6文件上传
1. asp
asp 上传文件真的蛋疼,很麻烦,有时候就用第三方组件,或者比较复杂的写法来实现无组件上传。
测试OK的一个叫风声无组件上传类 V2.1 [Fonshen UpLoadClass Version 2.1] :风声 ASP 上传组件
用.net程序测试:
private void button1_Click(object sender, EventArgs e)
{
string url = "http://localhost/UploadFileTest/demo1/upload.asp";
WebClient wc = new WebClient();
//wc.Headers.Add("Content-Type", "multipart/form-data");
string file = "d:\\33.mdb";
wc.UploadFileCompleted += new UploadFileCompletedEventHandler(wc_UploadFileCompleted);
wc.UploadProgressChanged += new UploadProgressChangedEventHandler(wc_UploadProgressChanged);
wc.UploadFileAsync(new Uri(url,UriKind.Absolute ), file ); } void wc_UploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
{
Text = ""+e.ProgressPercentage;
} void wc_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
{
MessageBox.Show(Encoding.UTF8.GetString(e.Result)); MessageBox.Show("upload ok");
}
2. ASP.NET
服务端:
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ if (Request.Files.Count > 0)
{
Request.Files[0].SaveAs(Server.MapPath("~/") + Path.GetFileName(Request.Files[0].FileName));
Label1.Text = "上传成功!";
}
else {
Label1.Text = "no file!";
} } }
客户端可以用上面那个 用.net程序测试。
改下 url = "http://localhost:4567/WebSite2/Default.aspx";//假如这个是服务端保存上传文件的东西。
3.VB6 上传文件
VB6 不好实现,可借用第三方组件:ChilkatHttp
Private Sub Command1_Click()
Dim url As String
url = "http://localhost:4567/WebSite2/Default.aspx" ' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
Dim TlsUnlockCode As String
TlsUnlockCode = "xxxxxxxxxxxxxxxx" '正式版解锁代码,需要购买 Dim http As New ChilkatHttp
unLockSuccess = http.UnlockComponent(TlsUnlockCode) 'or call UnlockComponetChilkatHttp(oHttpServer) Dim req As New ChilkatHttpRequest
req.HttpVerb = "POST"
req.contentType = "multipart/form-data"
req.Path = "WebSite2/Default.aspx" ' Send an "Expect: 100-continue" header in the request.
' This causes the HTTP server to end a 100-continue response
' immediately after receiving the HTTP header. The client
' (Chilkat) will receive this intermediate response, and if
' it's not an error response, it knows that the HTTP server will
' accept the data that is forthcoming.
' The alternative is to get an error response after trying to upload
' the entire contents of the files.
req.AddHeader "Expect", "100-continue" ' Call AddFileForUpload2 for each file to be uploaded in the HTTP multipart/form-data POST
' To allow Chilkat to determine the content-type automatically based on file-extension,
' call AddFileForUpload instead. ' The 1st arg is the filename passed in the HTTP request.
' The 2nd arg is the path in the local filesytem.
' The file is not loaded into memory. It is streamed directly from the file
' when the HTTP POST is sent.
Dim success As Long
success = req.AddFileForUpload("33.mdb", "d:/33.mdb") 'req.AddFileForUpload2("1.jpg", "d:/1.jpg", "image/jpg")
If (success <> 1) Then
MsgBox req.LastErrorText
Exit Sub
End If ' http://www.mywebserver123abc.com/rcvFormDataUpload.aspx
Dim resp As ChilkatHttpResponse
Set resp = http.SynchronousRequest("localhost", 4567, 0, req)
If (http.LastMethodSuccess <> 1) Then
Debug.Print http.LastErrorText
Else
Debug.Print "HTTP response status: " & resp.StatusCode
' See the online reference documentation for
' other information that can be obtained from the response object. End If Exit Sub
'------------------------------------------------------------------------
' To send using SSL/TLS, do this instead.
' This sends to https://www.mywebserver123abc.com/rcvFormDataUpload.aspx
Set resp = http.SynchronousRequest("www.mywebserver123abc.com", 443, 1, req)
If (http.LastMethodSuccess <> 1) Then
Debug.Print http.LastErrorText
Else
Debug.Print "HTTP response status: " & resp.StatusCode
' See the online reference documentation for
' other information that can be obtained from the response object. End If End Sub
ASP/ASP.NET/VB6文件上传的更多相关文章
- ASP.NET中的文件上传大小限制的问题
一.文件大小限制的问题 首先我们来说一下如何解决ASP.NET中的文件上传大小限制的问题,我们知道在默认情况下ASP.NET的文件上传大小限制为2M,一般情况下,我们可以采用更改WEB.Config文 ...
- Asp.net mvc 大文件上传 断点续传
Asp.net mvc 大文件上传 断点续传 进度条 概述 项目中需要一个上传200M-500M的文件大小的功能,需要断点续传.上传性能稳定.突破asp.net上传限制.一开始看到51CTO上的这 ...
- MVC图片上传、浏览、删除 ASP.NET MVC之文件上传【一】(八) ASP.NET MVC 图片上传到服务器
MVC图片上传.浏览.删除 1.存储配置信息 在web.config中,添加配置信息节点 <appSettings> <add key="UploadPath" ...
- iOS开发之结合asp.net webservice实现文件上传下载
iOS开发中会经常用到文件上传下载的功能,这篇文件将介绍一下使用asp.net webservice实现文件上传下载. 首先,让我们看下文件下载. 这里我们下载cnblogs上的一个zip文件.使用N ...
- ASP.NET MVC之文件上传【一】(八)
前言 这一节我们来讲讲在MVC中如何进行文件的上传,我们逐步深入,一起来看看. Upload File(一) 我们在默认创建的项目中的Home控制器下添加如下: public ActionResult ...
- 解决ASP.NET Core Mvc文件上传限制问题
一.简介 在ASP.NET Core MVC中,文件上传的最大上传文件默认为20MB,如果我们想上传一些比较大的文件,就不知道怎么去设置了,没有了Web.Config我们应该如何下手呢? 二.设置上传 ...
- ASP.NET MVC之文件上传【一】
前言 这一节我们来讲讲在MVC中如何进行文件的上传,我们逐步深入,一起来看看. Upload File(一) 我们在默认创建的项目中的Home控制器下添加如下: public ActionResult ...
- ASP.NET网络硬盘(文件上传,文件下载)
文件上传: 界面: 前台代码: <body style="text-align: center; background-image: url(Images/bg6.bmp);" ...
- asp.net core webapi文件上传
最近开发一个新项目,使用了asp.net core 2.0,采用webapi开发后台,postgresql为数据库.最先来的问题就是上传文件的问题. POST文件的一些坑 使用默认模板创建webapi ...
- ASP.NET对大文件上传的解决方案
在ASP.NET 开发的过程中,最大的问题就在于上传大文件时让开发者尤为的头疼,而且,上传时无法方便的做到多线程的操控和上传进度的显示.笔者在此给大家推荐一款简单易用的上传组件,从而快速便捷得解决了 ...
随机推荐
- 高级Bash脚本编程(一)
高级Bash脚本编程 Bash 它是能力很强的计算机语言,被称为解释性语言或脚本语言,它可以调用所有的UNIX命令和工具再加上公共程序. Bash中的特殊字符 注释(#) (除#!外,#!是用于指定当 ...
- ubuntu 18.04 64bit如何安装GPU版本tensorflow
注:笔者的ubuntu18.04 64bit已经安装好了显卡驱动,因此没有此步操作 1.获取cuda(https://developer.nvidia.com/cuda-downloads,选择ubu ...
- POJ 2443 Set Operation(压位加速)
http://poj.org/problem?id=2443 题意: 有1000个集合,每个集合有至多10000个数,之后输入多个询问,判断询问的两个数是否位于同一个集合. 思路: 位运算...很强大 ...
- mac上将代码上传到github以及github对100M以上文件限制上传的处理(lfs)。
前言 有时我们会写一些小程序来学习新的知识,但是完事之后过一段时间可能会忘记,最好的办法就是找到原来的代码看一看.现在可以将代码免费托管到一些网站上,其中最著名的非github莫属了, 今天就把这个过 ...
- bzoj1179: [Apio2009]Atm scc缩点+dag上dp
先把强连通缩点,然后变成了dag,dp求终点是酒吧的最长路即可, /************************************************************** Pro ...
- 过滤器系列(二)—— Cuckoo filter
这一篇讲的是布谷过滤器(cuckoo fliter),这个名字来源于更早发表的布谷散列(cuckoo hash),尽管我也不知道为什么当初要给这种散列表起个鸟名=_= 由于布谷过滤器本身的思想就源自于 ...
- iOS UILabel两端对齐的实现(可包括中英文/数字)
- (void)conversionCharacterInterval:(NSInteger)maxInteger current:(NSString *)currentString withLabe ...
- Centos 7 系统详解
安装CentOS 7系统后,变化竟然这么大? 一.Runlevel首先一条,原来一直用的CentOS-6.5-x86_64-minimal.iso光盘镜像(400M左右无图形系统小巧便捷),而7目 ...
- resin3.1处理utf-8格式的jsp时存在的问题
解决建议:http://cnxiaowei.iteye.com/blog/262766 /dqz/eh_sdxm/reporter/reporter_show_reportdraw_river.jsp ...
- 伴随我整十个年头的校内网,现名 人人网, 是不是要shut down 了
如题: 每天我都习惯性的登录人人网,虽然现在基本上已经看不到曾经的同学上线了,不过我还是有事没事的往上面post 一些出行的照片,没事无聊的时候上这个网上看看自己曾经的照片,虽然已经无人在线,但是自己 ...