1. asp

asp 上传文件真的蛋疼,很麻烦,有时候就用第三方组件,或者比较复杂的写法来实现无组件上传。

测试OK的一个叫风声无组件上传类 V2.1 [Fonshen UpLoadClass Version 2.1] :风声 ASP 上传组件

用.net程序测试:

  1. private void button1_Click(object sender, EventArgs e)
  2. {
  3. string url = "http://localhost/UploadFileTest/demo1/upload.asp";
  4. WebClient wc = new WebClient();
  5. //wc.Headers.Add("Content-Type", "multipart/form-data");
  6. string file = "d:\\33.mdb";
  7. wc.UploadFileCompleted += new UploadFileCompletedEventHandler(wc_UploadFileCompleted);
  8. wc.UploadProgressChanged += new UploadProgressChangedEventHandler(wc_UploadProgressChanged);
  9. wc.UploadFileAsync(new Uri(url,UriKind.Absolute ), file );
  10.  
  11. }
  12.  
  13. void wc_UploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
  14. {
  15. Text = ""+e.ProgressPercentage;
  16. }
  17.  
  18. void wc_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
  19. {
  20. MessageBox.Show(Encoding.UTF8.GetString(e.Result));
  21.  
  22. MessageBox.Show("upload ok");
  23. }

  

2. ASP.NET

服务端:

  1. using System.Web.Security;
  2. using System.Web.UI;
  3. using System.Web.UI.WebControls;
  4. using System.Web.UI.WebControls.WebParts;
  5. using System.Web.UI.HtmlControls;
  6. using System.IO;
  7. public partial class _Default : System.Web.UI.Page
  8. {
  9. protected void Page_Load(object sender, EventArgs e)
  10. {
  11.  
  12. if (Request.Files.Count > 0)
  13. {
  14. Request.Files[0].SaveAs(Server.MapPath("~/") + Path.GetFileName(Request.Files[0].FileName));
  15. Label1.Text = "上传成功!";
  16. }
  17. else {
  18. Label1.Text = "no file!";
  19. }
  20.  
  21. }
  22.  
  23. }

  

客户端可以用上面那个 用.net程序测试。

改下   url = "http://localhost:4567/WebSite2/Default.aspx";//假如这个是服务端保存上传文件的东西。

3.VB6 上传文件

VB6 不好实现,可借用第三方组件:ChilkatHttp

  1. Private Sub Command1_Click()
  2. Dim url As String
  3. url = "http://localhost:4567/WebSite2/Default.aspx"
  4.  
  5. ' This example requires the Chilkat API to have been previously unlocked.
  6. ' See Global Unlock Sample for sample code.
  7. Dim TlsUnlockCode As String
  8. TlsUnlockCode = "xxxxxxxxxxxxxxxx" '正式版解锁代码,需要购买
  9.  
  10. Dim http As New ChilkatHttp
  11. unLockSuccess = http.UnlockComponent(TlsUnlockCode) 'or call UnlockComponetChilkatHttp(oHttpServer)
  12.  
  13. Dim req As New ChilkatHttpRequest
  14. req.HttpVerb = "POST"
  15. req.contentType = "multipart/form-data"
  16. req.Path = "WebSite2/Default.aspx"
  17.  
  18. ' Send an "Expect: 100-continue" header in the request.
  19. ' This causes the HTTP server to end a 100-continue response
  20. ' immediately after receiving the HTTP header. The client
  21. ' (Chilkat) will receive this intermediate response, and if
  22. ' it's not an error response, it knows that the HTTP server will
  23. ' accept the data that is forthcoming.
  24. ' The alternative is to get an error response after trying to upload
  25. ' the entire contents of the files.
  26. req.AddHeader "Expect", "100-continue"
  27.  
  28. ' Call AddFileForUpload2 for each file to be uploaded in the HTTP multipart/form-data POST
  29. ' To allow Chilkat to determine the content-type automatically based on file-extension,
  30. ' call AddFileForUpload instead.
  31.  
  32. ' The 1st arg is the filename passed in the HTTP request.
  33. ' The 2nd arg is the path in the local filesytem.
  34. ' The file is not loaded into memory. It is streamed directly from the file
  35. ' when the HTTP POST is sent.
  36. Dim success As Long
  37. success = req.AddFileForUpload("33.mdb", "d:/33.mdb") 'req.AddFileForUpload2("1.jpg", "d:/1.jpg", "image/jpg")
  38. If (success <> 1) Then
  39. MsgBox req.LastErrorText
  40. Exit Sub
  41. End If
  42.  
  43. ' http://www.mywebserver123abc.com/rcvFormDataUpload.aspx
  44. Dim resp As ChilkatHttpResponse
  45. Set resp = http.SynchronousRequest("localhost", 4567, 0, req)
  46. If (http.LastMethodSuccess <> 1) Then
  47. Debug.Print http.LastErrorText
  48. Else
  49. Debug.Print "HTTP response status: " & resp.StatusCode
  50. ' See the online reference documentation for
  51. ' other information that can be obtained from the response object.
  52.  
  53. End If
  54.  
  55. Exit Sub
  56. '------------------------------------------------------------------------
  57. ' To send using SSL/TLS, do this instead.
  58. ' This sends to https://www.mywebserver123abc.com/rcvFormDataUpload.aspx
  59. Set resp = http.SynchronousRequest("www.mywebserver123abc.com", 443, 1, req)
  60. If (http.LastMethodSuccess <> 1) Then
  61. Debug.Print http.LastErrorText
  62. Else
  63. Debug.Print "HTTP response status: " & resp.StatusCode
  64. ' See the online reference documentation for
  65. ' other information that can be obtained from the response object.
  66.  
  67. End If
  68.  
  69. 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. 20145329 《网络对抗技术》PC平台逆向破解

    shellcode注入 实践是在非常简单的一个预设条件下完成的: (1)关闭堆栈保护 (2)关闭堆栈执行保护 (3)关闭地址随机化 (4)在x32环境下 (5)在Linux实践环境 shellcode ...

  2. 20145219《网络对抗》Web安全基础实践

    20145219<网络对抗>Web安全基础实践 基础问题回答 SQL注入攻击原理,如何防御? 原理:SQL注入攻击指的是通过构建特殊的输入作为参数传入Web应用程序,而这些输入大都是SQL ...

  3. @Bean 生命周期

    bean生命周期: 实例bean 1.当调用者通过getBean(beanName)向容器请求某一个Bean时,如果容器注册了org.springframework.beans.factory.con ...

  4. 【bzoj2721】[Violet 5]樱花

    题目传送门:https://www.lydsy.com/JudgeOnline/problem.php?id=2721 好久没做数学题了,感觉有些思想僵化,走火入魔了. 这道题就是求方程$ \frac ...

  5. 使用IDEA创建基于Gradle构建的JavaWeb项目

    环境配置 jdk: 1.8 Gradle: 4.4.1 Tomcat: 9.0.0 One Step! 创建项目,初始化项目结构. 打开我们的IDEA,进入创建项目的界面,勾选Java,Web两个选项 ...

  6. Hive之基本操作

    1,CREATE table. CREATE [EXTERNAL] TABLE [IF NOT EXISTS] table_name [(col_name data_type [COMMENT col ...

  7. OATable中column栏位数据居中的实现方法及代码

    // Table column中显示居中的实现 // QpriceResultTable1 为table的名称 // noPrice 为table中的列 OATableBean table = (OA ...

  8. MySQL_explain关键字分析查询语句

    版权声明:本文为博主原创文章,转载请注明出处. 通过对查询语句的分析,可以了解查询语句的执行情况.MySQL中,可以使用EXPLAIN语句和DESCRIBE语句来分析查询语句. EXPLAIN语句的基 ...

  9. Alpha冲刺 (4/10)

    前言 队名:拖鞋旅游队 组长博客:https://www.cnblogs.com/Sulumer/p/9979357.html 作业博客:https://edu.cnblogs.com/campus/ ...

  10. @InitBinder装配自定义编辑器

    @InitBinder装配自定义编辑器 第一步:BaseController.java,标注@InitBinder public class BaseController { @InitBinder ...