Important alert: (current site time 7/16/2013 12:06:25 AM EDT)
 

winzip icon

Upload a file to your Web via HTTP

Email
Submitted on: 2/21/2000 1:00:00 PM
By: Klemens Schmid (old)  
Level: Intermediate
User Rating: By 6 Users
Compatibility: ASP (Active Server Pages)
Views: 36613
 
     This code uploads a file to an ASP script using http post. It can be used to automatically uploading files without user interaction, e.g. when you want to publish some data to your Web site periodically. There are lots of code excerpts around describing the receiving side but the sending side is mostly an HTML page containing INPUT TYPE="File" ... Simulating this by code requires some knowledge of HTTP Post and Mime. Find the full project and the ASP in the ZIP.

The project uses the XMLHTTPRequest object in Microsoft XML v2.6. The version 2.0 didn't work for this. It is part of the Microsoft Technology Preview for XML/XSL. It can be found at http://msdn.microsoft.com/downloads/webtechnology/xml/msxml.asp.
 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

5/8/2000 3:13:00 AMeformx

microsoft is distributing v3.0 of xml

the code does not work. any tips/thoughts.

thanks, Rob.
(If this comment was disrespectful, please report it.)

 
5/8/2000 3:15:13 AMeformx

changed the code to ...

Dim oHttp As XMLHTTP30

'make use of the XMLHTTPRequest object contained in msxml.dll
Set oHttp = New XMLHTTP30

where XMLHTTP26 was in your original code. it now works.

Rob
(If this comment was disrespectful, please report it.)

 
5/14/2000 5:21:38 PMKSD

Whether you need XMLHTTP30 or XMLHTTP26 depends on which release of the XML technology preview you downloaded. The March release includes the XMLHTTP30.
(If this comment was disrespectful, please report it.)

 
8/4/2000 2:50:40 PMJason R. Fayling

Thank you for submitting this code. I have been looking for something along this line. I need to do exactly what you are doing, but I need to add another field of info. Where can I get more information about HTTP Post and Mime so that I can create the mime code to accomplish my task?

Thanks for you time.
(If this comment was disrespectful, please report it.)

 
8/28/2000 12:52:56 PMKlemens

For HTTP Post and MIME you may consult the RFC: http://www.cis.ohio-state.edu/htbin/rfc/rfc1867.html
(If this comment was disrespectful, please report it.)

 
10/14/2000 12:11:36 PMKlemens Schmid

Many people ask me how to upload a binary file like a gif or jpg. I never did it but the following link to RFC 1867 may help:
http://www.cis.ohio-state.edu/htbin/rfc/rfc1867.html
(If this comment was disrespectful, please report it.)

 
5/15/2001 10:05:33 PMgus

I need to do the similar file upload with NO using of But do you have example of doing this from a ASP script rather than from a VB program?
(If this comment was disrespectful, please report it.)

 
5/22/2001 10:21:58 AMBhanu

I am really interested in the code for
(If this comment was disrespectful, please report it.)

 
5/22/2001 10:26:58 AMBhanu

Sorry about the previous post, something
went wrong there. I needed to know if
you could share the code for the COM
object "aspSmartUpload". I would really
appreciate it if you did.
(If this comment was disrespectful, please report it.)

 
6/9/2001 6:09:56 PMKlemens Schmid

aspSmartUpload is a freely available component from http://www.aspsmart.com/. It is not under my control. Sorry.
(If this comment was disrespectful, please report it.)

 
6/13/2001 11:45:21 AMRik

Hi,

Wonder if you can help me this? Tried for months to work this out

I want to be able to get a VB app to automatically upload itself to my sever as a backup at a defined time i.e 02:00hours. This will then find the port and connect via ftp.

Then I want another app in another location to connect to the same server and download all or specific files from the 'Backup'

In addition and to save time I want the app to 'compare' itself to updated files for the app itself so that whenever I make any updates for the app I will save them to my server. So when it checks with my server it will compare itself and if it sees such updates will automaically download them over writing the 'old' scripts in the app.

Does this make sense?.......

Hope you can help

Rik

P.S If you can help I will be more than willing to send you a 'Thank You' by way of a payment.
(If this comment was disrespectful, please report it.)

 
7/11/2001 1:43:16 PMNick

For those of you who want to upload binary data, there is a complete set of VB code that will take binary data and create MIME-encoded (Base64) strings suitable for uploading. The code lives at: http://di-mgt.com.au/crypto.html

--- Nick
(If this comment was disrespectful, please report it.)

 
7/16/2001 5:27:25 PMRanjeev

Can you please suggest once Upload is done we wish to check for the virus ?
Do you know any product which got the developer SDK
(If this comment was disrespectful, please report it.)

 
7/16/2001 5:28:52 PMrk

How can we scan the uploaded file for virus

(If this comment was disrespectful, please report it.)

 
7/17/2001 4:56:35 PMKlemens Schmid

No idea. My upload code assume that on the server side there is aspSmartUpload receiving the file. This product should have a virus interface or you should take another product instead. As far as I know there are no standardized virus interfaces yet.
(If this comment was disrespectful, please report it.)

 
7/19/2001 10:54:04 PMDan

How can i upload binary file(ex:gif file)??
(If this comment was disrespectful, please report it.)

 
7/20/2001 6:40:22 AMKlemens Schmid

For uploading a binary file see the code on my home page at http://www.schmidks.de/tools.htm. The time will come that I also update this code here.
(If this comment was disrespectful, please report it.)

 
1/3/2003 5:13:49 AM

Iam not able to attach files of say size 1 mb. What could be the problem?
(If this comment was disrespectful, please report it.)

 
11/5/2006 4:46:09 PMKevin Ritch

Better late than nexer :-)

Here's 5 Globes from me Groovy Dude!

Cheers,
Kevin
PS - Yes, I also used the BINARY VERSION from your website! EXCELLENT
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.