<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Multipart Form Post in C#</title>
	<atom:link href="http://www.briangrinstead.com/blog/multipart-form-post-in-c/feed" rel="self" type="application/rss+xml" />
	<link>http://www.briangrinstead.com/blog/multipart-form-post-in-c</link>
	<description></description>
	<lastBuildDate>Tue, 31 Aug 2010 17:57:34 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Stephen</title>
		<link>http://www.briangrinstead.com/blog/multipart-form-post-in-c/comment-page-1#comment-7122</link>
		<dc:creator>Stephen</dc:creator>
		<pubDate>Tue, 31 Aug 2010 17:57:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.briangrinstead.com/?p=119#comment-7122</guid>
		<description>Absolutely fantastic post. Hve been working on this for the past two days to no avail. I&#039;ve been trying to programatically post files to a unix server and it does not help when when the Java guys 
a) Decide to use a form post method for posting files when FTP would adequately do the Job
b) Give you Zero support when their unix server just returns &quot;403&quot; bad request, apparently they get nothing in the logs

If anyone is interested in using basic authentication with this code, 

after the line  
&lt;pre lang=&#039;csharp&#039;&gt;
request.ContentLength = formData.Length;
&lt;/pre&gt;

like I had to add the following to get it to work for me, 

 &lt;pre lang=&#039;csharp&#039;&gt;
request.PreAuthenticate = true;
request.AuthenticationLevel = System.Net.Security.AuthenticationLevel.MutualAuthRequested;
request.Headers.Add(&quot;Authorization&quot;, &quot;Basic &quot; + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(&quot;username&quot; + &quot;:&quot; + &quot;password&quot;)));
&lt;/pre&gt;

I also wrapped the FileStream and StreamReader object in my caller method  within using blocks, which is just decorative/programming style stuff really if you wish.</description>
		<content:encoded><![CDATA[<p>Absolutely fantastic post. Hve been working on this for the past two days to no avail. I&#8217;ve been trying to programatically post files to a unix server and it does not help when when the Java guys<br />
a) Decide to use a form post method for posting files when FTP would adequately do the Job<br />
b) Give you Zero support when their unix server just returns &#8220;403&#8243; bad request, apparently they get nothing in the logs</p>
<p>If anyone is interested in using basic authentication with this code, </p>
<p>after the line</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">request.<span style="color: #0000FF;">ContentLength</span> <span style="color: #008000;color: #000000;">=</span> formData.<span style="color: #0000FF;">Length</span><span style="color: #008000;color: #000000;">;</span></pre></div></div>

<p>like I had to add the following to get it to work for me,</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">request.<span style="color: #0000FF;">PreAuthenticate</span> <span style="color: #008000;color: #000000;">=</span> true<span style="color: #008000;color: #000000;">;</span>
request.<span style="color: #0000FF;">AuthenticationLevel</span> <span style="color: #008000;color: #000000;">=</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Net</span></span>.<span style="color: #0000FF;">Security</span>.<span style="color: #0000FF;">AuthenticationLevel</span>.<span style="color: #0000FF;">MutualAuthRequested</span><span style="color: #008000;color: #000000;">;</span>
request.<span style="color: #0000FF;">Headers</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;color: #000000;">&#40;</span><span style="color: #666666;color: #808080;">&quot;Authorization&quot;</span>, <span style="color: #666666;color: #808080;">&quot;Basic &quot;</span> <span style="color: #008000;color: #000000;">+</span> Convert.<span style="color: #0000FF;">ToBase64String</span><span style="color: #000000;color: #000000;">&#40;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Text</span></span>.<span style="color: #0000FF;">Encoding</span>.<span style="color: #0600FF;color: #0000FF;">Default</span>.<span style="color: #0000FF;">GetBytes</span><span style="color: #000000;color: #000000;">&#40;</span><span style="color: #666666;color: #808080;">&quot;username&quot;</span> <span style="color: #008000;color: #000000;">+</span> <span style="color: #666666;color: #808080;">&quot;:&quot;</span> <span style="color: #008000;color: #000000;">+</span> <span style="color: #666666;color: #808080;">&quot;password&quot;</span><span style="color: #000000;color: #000000;">&#41;</span><span style="color: #000000;color: #000000;">&#41;</span><span style="color: #000000;color: #000000;">&#41;</span><span style="color: #008000;color: #000000;">;</span></pre></div></div>

<p>I also wrapped the FileStream and StreamReader object in my caller method  within using blocks, which is just decorative/programming style stuff really if you wish.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: diss3ntive</title>
		<link>http://www.briangrinstead.com/blog/multipart-form-post-in-c/comment-page-1#comment-5870</link>
		<dc:creator>diss3ntive</dc:creator>
		<pubDate>Wed, 23 Jun 2010 02:25:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.briangrinstead.com/?p=119#comment-5870</guid>
		<description>I.....Love......Youuuuuu</description>
		<content:encoded><![CDATA[<p>I&#8230;..Love&#8230;&#8230;Youuuuuu</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pykaso</title>
		<link>http://www.briangrinstead.com/blog/multipart-form-post-in-c/comment-page-1#comment-5320</link>
		<dc:creator>Pykaso</dc:creator>
		<pubDate>Mon, 10 May 2010 13:29:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.briangrinstead.com/?p=119#comment-5320</guid>
		<description>For UTF-8 encoded form data im using:
&lt;pre lang=&quot;csharp&quot;&gt;
formDataStream.Write(encoding.GetBytes(postData), 0, encoding.GetByteCount(postData));
&lt;/pre&gt;

instead of:
&lt;pre lang=&quot;csharp&quot;&gt;
formDataStream.Write(encoding.GetBytes(postData), 0, postData.Length);
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>For UTF-8 encoded form data im using:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">formDataStream.<span style="color: #0000FF;">Write</span><span style="color: #000000;color: #000000;">&#40;</span>encoding.<span style="color: #0000FF;">GetBytes</span><span style="color: #000000;color: #000000;">&#40;</span>postData<span style="color: #000000;color: #000000;">&#41;</span>, <span style="color: #FF0000;color: #808080;">0</span>, encoding.<span style="color: #0000FF;">GetByteCount</span><span style="color: #000000;color: #000000;">&#40;</span>postData<span style="color: #000000;color: #000000;">&#41;</span><span style="color: #000000;color: #000000;">&#41;</span><span style="color: #008000;color: #000000;">;</span></pre></div></div>

<p>instead of:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">formDataStream.<span style="color: #0000FF;">Write</span><span style="color: #000000;color: #000000;">&#40;</span>encoding.<span style="color: #0000FF;">GetBytes</span><span style="color: #000000;color: #000000;">&#40;</span>postData<span style="color: #000000;color: #000000;">&#41;</span>, <span style="color: #FF0000;color: #808080;">0</span>, postData.<span style="color: #0000FF;">Length</span><span style="color: #000000;color: #000000;">&#41;</span><span style="color: #008000;color: #000000;">;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://www.briangrinstead.com/blog/multipart-form-post-in-c/comment-page-1#comment-4554</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Fri, 09 Apr 2010 01:09:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.briangrinstead.com/?p=119#comment-4554</guid>
		<description>Brian - outstanding!  Really helped...

Matt</description>
		<content:encoded><![CDATA[<p>Brian &#8211; outstanding!  Really helped&#8230;</p>
<p>Matt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Turkel</title>
		<link>http://www.briangrinstead.com/blog/multipart-form-post-in-c/comment-page-1#comment-3620</link>
		<dc:creator>Turkel</dc:creator>
		<pubDate>Sat, 06 Mar 2010 08:57:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.briangrinstead.com/?p=119#comment-3620</guid>
		<description>Hi Mr Brian

I need your help about that post.

First

I have php file that gets data and file from HTML form and uploads file to specific directory by $_FILES methods..

Second

I have windos aplication (c#).User could drag and drop any file to listview.When he/She clicks send button aplication sends datas of user to php file By POST method and it (php file) upadtes the database.

My problem is I wont to send file in listview drag and dropeed by user to php file as It could get file by $_FILES method and acces it.Sory about my english

thanks.what do I have to do by your post?</description>
		<content:encoded><![CDATA[<p>Hi Mr Brian</p>
<p>I need your help about that post.</p>
<p>First</p>
<p>I have php file that gets data and file from HTML form and uploads file to specific directory by $_FILES methods..</p>
<p>Second</p>
<p>I have windos aplication (c#).User could drag and drop any file to listview.When he/She clicks send button aplication sends datas of user to php file By POST method and it (php file) upadtes the database.</p>
<p>My problem is I wont to send file in listview drag and dropeed by user to php file as It could get file by $_FILES method and acces it.Sory about my english</p>
<p>thanks.what do I have to do by your post?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mithun</title>
		<link>http://www.briangrinstead.com/blog/multipart-form-post-in-c/comment-page-1#comment-2323</link>
		<dc:creator>Mithun</dc:creator>
		<pubDate>Wed, 10 Feb 2010 12:24:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.briangrinstead.com/?p=119#comment-2323</guid>
		<description>Awsome post!!! Thanks for helping us out of the drudgery.... This saved a lot of time in my work.... May be this should be added as a part of the C# library.</description>
		<content:encoded><![CDATA[<p>Awsome post!!! Thanks for helping us out of the drudgery&#8230;. This saved a lot of time in my work&#8230;. May be this should be added as a part of the C# library.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Corey</title>
		<link>http://www.briangrinstead.com/blog/multipart-form-post-in-c/comment-page-1#comment-2310</link>
		<dc:creator>Corey</dc:creator>
		<pubDate>Tue, 09 Feb 2010 14:21:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.briangrinstead.com/?p=119#comment-2310</guid>
		<description>This class worked great for posting a multipart form in c sharp. Thanks!</description>
		<content:encoded><![CDATA[<p>This class worked great for posting a multipart form in c sharp. Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pkpo</title>
		<link>http://www.briangrinstead.com/blog/multipart-form-post-in-c/comment-page-1#comment-1833</link>
		<dc:creator>Pkpo</dc:creator>
		<pubDate>Mon, 14 Dec 2009 16:16:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.briangrinstead.com/?p=119#comment-1833</guid>
		<description>I love you !</description>
		<content:encoded><![CDATA[<p>I love you !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Sheehan</title>
		<link>http://www.briangrinstead.com/blog/multipart-form-post-in-c/comment-page-1#comment-1638</link>
		<dc:creator>John Sheehan</dc:creator>
		<pubDate>Wed, 02 Dec 2009 01:10:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.briangrinstead.com/?p=119#comment-1638</guid>
		<description>Hi Brian, can you email me in regards to the code in this post? Or can you acknowledge if this code is under any sort of license?</description>
		<content:encoded><![CDATA[<p>Hi Brian, can you email me in regards to the code in this post? Or can you acknowledge if this code is under any sort of license?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Upload a File via WebRequest Using CSharp</title>
		<link>http://www.briangrinstead.com/blog/multipart-form-post-in-c/comment-page-1#comment-1307</link>
		<dc:creator>Upload a File via WebRequest Using CSharp</dc:creator>
		<pubDate>Tue, 10 Nov 2009 14:15:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.briangrinstead.com/?p=119#comment-1307</guid>
		<description>[...] Brian Grinstead » Blog Archive » Multipart Form Post in C# &#8211; So, I needed to roll my own form post. Here is the Multipart Form RFC and the W3C Specification for multipart/form data. After reading these links and searching some forums, here is what I came up with. &#8230;.. userAgent, contentType, formData) End Function Private Function PostForm(ByVal postUrl As String, _ ByVal userAgent As String, _ ByVal contentType As String, _ ByVal formData As Byte()) _ As HttpWebResponse Try Dim request As HttpWebRequest = WebRequest. &#8230; [...]</description>
		<content:encoded><![CDATA[<p>[...] Brian Grinstead » Blog Archive » Multipart Form Post in C# &#8211; So, I needed to roll my own form post. Here is the Multipart Form RFC and the W3C Specification for multipart/form data. After reading these links and searching some forums, here is what I came up with. &#8230;.. userAgent, contentType, formData) End Function Private Function PostForm(ByVal postUrl As String, _ ByVal userAgent As String, _ ByVal contentType As String, _ ByVal formData As Byte()) _ As HttpWebResponse Try Dim request As HttpWebRequest = WebRequest. &#8230; [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
