Solved

Using POST to send a file to a web server...

Posted on 2004-04-29
6
190 Views
Last Modified: 2010-04-24
Hi,

Part of a program I'm writing needs to send a file to a remote server. Rather than using FTP, I think it would be an advantage to 'post' it to a page on the server (as I could also send additonal fields of data).

I can easily write a asp.net page at the server end that will accept a file that has been posted (it works with a form and a 'file' field), but what i need to do is write the code in vb.net that posts the file.

Ive found code that will post a form (using HttpRequest and HttpResponse), however I cant find out how to add a file to the datastream.

Any help would be great!

Many thanks,

Tim Alston

0
Comment
Question by:Backflipping
  • 3
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11123149
You can use a StreamReader to get a file into a stream that you can feed to the Response stream, but I am not sure how that will be handled.  This technique can be used to process an image, and then have it rendered at the browser.

Bob
0
 

Author Comment

by:Backflipping
ID: 11123412
Hi Bob,

Yes, I think that a Stream will be the way to do this - and I have used the StreamWriter and Response stream for images (sizing, compressing and then passing directly to the browser). It's the posting part however that I'm unsure how to do??? (And it seems maybe nobody does, as this topic has been here a while now!).

Thanks,

Tim
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11125761
I am not exactly sure if I do either, but since I am the Cleanup volunteer for this Topic Area, I come across these questions all the time.

E-E is the perfect opportunity for me to teach and learn.  It gives me the chance to work outside of the box.  Also, I have a few contacts that might be able to find the answer to your question.  Along the way, I get to learn about something that I find very interesting.

Given the chance, I think that I can always find a solution, but I guess that comes from the eternal optimist in me.

Bob
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 465 total points
ID: 11142339
Would the HTTPResponse.WriteFile method do what you want?

Bob
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now