Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

919 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

18 Experts available now in Live!

Get 1:1 Help Now