Solved

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

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

791 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