all groups > c# > july 2004 >
You're in the

c#

group:

Send file to server by HTTP-Post method


Send file to server by HTTP-Post method Evgeny Zoldin
7/11/2004 11:29:50 PM
c#: Hi ALL.

I would like to download file from some web-server that requires
Basic-Authetication, change somthing in the file and upload it back to the
server.
I can download the file and proceed as I need, but how should I upload it
back? Server provides standard HTML GUI for Browsers where client can fill
appropriate input field of the form with a full name of the local file. The
form uses POST method to upload file and has attribute

enctype="multipart/form-data"

What the simplest way to upload file programmatically? Is it possible to
control the uploading process if any?

Thanx
Evgeny

Re: Send file to server by HTTP-Post method Richard Bower
7/12/2004 10:29:12 AM
Save posted file:
C#
((HttpPostedFile)HttpContext.Current.Request.Files[<filename>]).SaveAs(
<savetolocation> ) ;


[quoted text, click to view]

Re: Send file to server by HTTP-Post method Scott Allen
7/12/2004 10:46:21 AM
I have an article with some tips on using WebClient and WebRequest to
post data, though it doesn't deal with file upload specifically:
http://odetocode.com/Articles/162.aspx

The article references a tool "Fiddler", which is an Http Debugging
Proxy and a great way to see "how your browser does it".

HTH,

--
Scott
http://www.OdeToCode.com

On Sun, 11 Jul 2004 23:29:50 +0200, "Evgeny Zoldin"
[quoted text, click to view]
Re: Send file to server by HTTP-Post method Jerry Pisk
7/12/2004 3:49:27 PM
I think you're asking whether you can automatically upload a file, without
the user interaction. The short answer is no, you can't. It would be a huge
security hole into the system. You will have to install an ActiveX control
(and be careful, .Net user controls will not help you here as they are
hosted in a secure environment) that would read the file and upload it. But
then again, unless you do it really well (as in only upload to a known host
name, over SSL) you will open a security hole into whoever installs the
control.

Jerry

[quoted text, click to view]

Re: Send file to server by HTTP-Post method Joerg Jooss
7/17/2004 10:23:40 PM
[quoted text, click to view]

There's no "simple way" -- what you want is a proper implementation of
http://www.faqs.org/rfcs/rfc2388.html, based on
HttpWebRequest/HttpWebResponse. WebClient.UploadFile() should have been
that, but has a bug that may cause some server-side upload facilities (like
PHP) to fail.

Cheers,

--
Joerg Jooss
joerg.jooss@gmx.net
AddThis Social Bookmark Button