Solved

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

Posted on 2004-04-29
6
195 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

777 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