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文件上传的更多相关文章

  1. ASP.NET中的文件上传大小限制的问题

    一.文件大小限制的问题 首先我们来说一下如何解决ASP.NET中的文件上传大小限制的问题,我们知道在默认情况下ASP.NET的文件上传大小限制为2M,一般情况下,我们可以采用更改WEB.Config文 ...

  2. Asp.net mvc 大文件上传 断点续传

    Asp.net mvc 大文件上传 断点续传 进度条   概述 项目中需要一个上传200M-500M的文件大小的功能,需要断点续传.上传性能稳定.突破asp.net上传限制.一开始看到51CTO上的这 ...

  3. MVC图片上传、浏览、删除 ASP.NET MVC之文件上传【一】(八) ASP.NET MVC 图片上传到服务器

    MVC图片上传.浏览.删除   1.存储配置信息 在web.config中,添加配置信息节点 <appSettings> <add key="UploadPath" ...

  4. iOS开发之结合asp.net webservice实现文件上传下载

    iOS开发中会经常用到文件上传下载的功能,这篇文件将介绍一下使用asp.net webservice实现文件上传下载. 首先,让我们看下文件下载. 这里我们下载cnblogs上的一个zip文件.使用N ...

  5. ASP.NET MVC之文件上传【一】(八)

    前言 这一节我们来讲讲在MVC中如何进行文件的上传,我们逐步深入,一起来看看. Upload File(一) 我们在默认创建的项目中的Home控制器下添加如下: public ActionResult ...

  6. 解决ASP.NET Core Mvc文件上传限制问题

    一.简介 在ASP.NET Core MVC中,文件上传的最大上传文件默认为20MB,如果我们想上传一些比较大的文件,就不知道怎么去设置了,没有了Web.Config我们应该如何下手呢? 二.设置上传 ...

  7. ASP.NET MVC之文件上传【一】

    前言 这一节我们来讲讲在MVC中如何进行文件的上传,我们逐步深入,一起来看看. Upload File(一) 我们在默认创建的项目中的Home控制器下添加如下: public ActionResult ...

  8. ASP.NET网络硬盘(文件上传,文件下载)

    文件上传: 界面: 前台代码: <body style="text-align: center; background-image: url(Images/bg6.bmp);" ...

  9. asp.net core webapi文件上传

    最近开发一个新项目,使用了asp.net core 2.0,采用webapi开发后台,postgresql为数据库.最先来的问题就是上传文件的问题. POST文件的一些坑 使用默认模板创建webapi ...

  10. ASP.NET对大文件上传的解决方案

    在ASP.NET 开发的过程中,最大的问题就在于上传大文件时让开发者尤为的头疼,而且,上传时无法方便的做到多线程的操控和上传进度的显示.笔者在此给大家推荐一款简单易用的上传组件,从而快速便捷得解决了 ...

随机推荐

  1. 使用索贝尔(Sobel)进行梯度运算时的数学意义和代码实现研究

    对于做图像处理的工程师来说,Sobel非常熟悉且常用.但是当我们需要使用Sobel进行梯度运算,且希望得到“数学结果”(作为下一步运算的基础)而不是“图片效果”的时候,就必须深入了解Sobel的知识原 ...

  2. 实验四——使用库函数API和C代码中嵌入汇编代码两种方式使用同一个系统调用

    实验目的: 使用库函数API和C代码中嵌入汇编代码两种方式使用同一个系统调用 实验过程: 查看系统调用列表 get pid 函数 #include <stdio.h> #include & ...

  3. 20145211《网络对抗》逆向及BOF基础实践

    逆向及BOF基础实践——又是一年梅落时 一.实践目标 本次实践的对象是一个名为pwn1的linux可执行文件. 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任何用户输入的字符串. ...

  4. HeyWeGo小组《Java程序设计》 2015—2016年学期团队项目总结

    HeyWeGo小组<Java程序设计> 2015—2016年学期团队项目总结 题目简介 一个简单的扫雷小游戏,在12*12的方格盘上,首先可以设定雷的个数,然后点击开始程序就会随机布雷,开 ...

  5. 将vi打造成IDE

    一.环境 发行版:Ubuntu 18.04 LTS 代号:bionic 内核版本:4.15.0-33-generic 二.步骤 2.1 准备工作 sudo apt-get install python ...

  6. POJ 1122 FDNY to the Rescue!(最短路+路径输出)

    http://poj.org/problem?id=1122 题意:给出地图并且给出终点和多个起点,输出从各个起点到终点的路径和时间. 思路: 因为有多个起点,所以这里反向建图,这样就相当于把终点变成 ...

  7. Template Method(模板方法)

    意图: 定义一个操作中的算法的骨架,而将一些步骤延迟到子类中.TemplateMethod 使得子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤. 适用性: 一次性实现一个算法的不变的部分, ...

  8. [转] VR-FORCES 介绍

    转自:https://sanwen8.cn/p/1e6GQeK.html 今天给各位介绍的仿真平台是VR-Forces.VR-Forces是新加坡公司MAK的产品,前身是美国公司.在仿真平台领域里面, ...

  9. [原][osg][osgearth]我眼中的osgearth

    看了一下,OE生成的可执行文件 除了osg库和第三方库 OE生产最多的dll就是 osgdb_osgearth_XXXX.dll了 这些都是为了通过osgDB机制加载earth的数据用的. 所以,我觉 ...

  10. java并发编程:线程安全管理类--原子包--java.util.concurrent.atomic

    java.util.concurrent.atomic 的描述 AtomicBoolean 可以用原子方式更新的 boolean 值. AtomicInteger 可以用原子方式更新的 int 值. ...