<?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: How do i upload a file to the client using asp?</title>
	<atom:link href="http://www.bugfindr.com/4844/how-do-i-upload-a-file-to-the-client-using-asp.html/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bugfindr.com/4844/how-do-i-upload-a-file-to-the-client-using-asp.html</link>
	<description>Smashing resource for tech people</description>
	<lastBuildDate>Wed, 09 Jun 2010 18:59:23 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6-beta1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: vbslinger</title>
		<link>http://www.bugfindr.com/4844/how-do-i-upload-a-file-to-the-client-using-asp.html/comment-page-1#comment-1563</link>
		<dc:creator>vbslinger</dc:creator>
		<pubDate>Sat, 20 Mar 2010 10:36:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.bugfindr.com/4844/how-do-i-upload-a-file-to-the-client-using-asp.html#comment-1563</guid>
		<description>I think what you want to do is stream a binary to the client.

What I describe here, you&#039;d put in the Button_Click event and would cause a pop-up to appear on the client screen that gives the option to save, open or cancel.  Bear in mind - there is no web code that allows you to just write to a client computer - that&#039;s called a Trojan Horse (yeah, yeah -some people are stupid and let you do it, but you shouldn&#039;t write you code to assume that).

But, this code should get you moving along the path I think you want to take.

Use the Response object, just like you&#039;d do Response.Write.
However, instead do this: 
BinaryStream myStream = SomeFunctionToGetStream
Response.BufferOutput = true
Response.ClearHeaders()
Response.ClearContent()
Response.Write(&quot;content-disposition&quot;,&quot;inline;filename=MyFile.txt&quot;);
Response.AddHeader(&quot;content-length&quot;, myStream.length)
Response.BinaryWrite(myStream);
Response.Flush

I&#039;m probably missing a command or two since I&#039;m doing this off my head - I don&#039;t write this specific type of code much - instead I just wrap it up in a class.  Anyhoo - seach on BinaryWrite and those other commands and you should be able  to find a real example.</description>
		<content:encoded><![CDATA[<p>I think what you want to do is stream a binary to the client.</p>
<p>What I describe here, you&#8217;d put in the Button_Click event and would cause a pop-up to appear on the client screen that gives the option to save, open or cancel.  Bear in mind &#8211; there is no web code that allows you to just write to a client computer &#8211; that&#8217;s called a Trojan Horse (yeah, yeah -some people are stupid and let you do it, but you shouldn&#8217;t write you code to assume that).</p>
<p>But, this code should get you moving along the path I think you want to take.</p>
<p>Use the Response object, just like you&#8217;d do Response.Write.<br />
However, instead do this:<br />
BinaryStream myStream = SomeFunctionToGetStream<br />
Response.BufferOutput = true<br />
Response.ClearHeaders()<br />
Response.ClearContent()<br />
Response.Write(&#8221;content-disposition&#8221;,&#8221;inline;filename=MyFile.txt&#8221;);<br />
Response.AddHeader(&#8221;content-length&#8221;, myStream.length)<br />
Response.BinaryWrite(myStream);<br />
Response.Flush</p>
<p>I&#8217;m probably missing a command or two since I&#8217;m doing this off my head &#8211; I don&#8217;t write this specific type of code much &#8211; instead I just wrap it up in a class.  Anyhoo &#8211; seach on BinaryWrite and those other commands and you should be able  to find a real example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rex M</title>
		<link>http://www.bugfindr.com/4844/how-do-i-upload-a-file-to-the-client-using-asp.html/comment-page-1#comment-1562</link>
		<dc:creator>Rex M</dc:creator>
		<pubDate>Sat, 20 Mar 2010 10:25:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.bugfindr.com/4844/how-do-i-upload-a-file-to-the-client-using-asp.html#comment-1562</guid>
		<description>That would be called &quot;downloading&quot; and would be done by giving the user a link to the file on the server.

Edit: Then make the button redirect to the file instead of using a link. The easiest way would probably just be to use JavaScript... write a function that redirects to the file you want them to download, and have the button onClick event invoke the function.</description>
		<content:encoded><![CDATA[<p>That would be called &#8220;downloading&#8221; and would be done by giving the user a link to the file on the server.</p>
<p>Edit: Then make the button redirect to the file instead of using a link. The easiest way would probably just be to use JavaScript&#8230; write a function that redirects to the file you want them to download, and have the button onClick event invoke the function.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
