content-disposition

Download textarea contents as a file using only Javascript (no server-side)

好久不见. 提交于 2019-11-27 04:04:11
I am being asked to make a "download" button that downloads the contents of a textarea on the same page as a file, with the browser's "Save As..." dialog showing up. Copy/paste would do the job just fine, but it is a "requirement". Right now, I am just posting the contents of the textarea to the server, which echos them back with Content-disposition: attachment slapped on. Is there a way to do this with just client-side Javascript? NatureShade This may be what you are looking for: http://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/

PDF Handler : content-disposition filename

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 01:58:04
问题 I am outputting a PDF file in a Web browser (IE8) HttpContext.Response.writefile(fileName) and it works great. When I try to save the file, it will give me the name of the ashx handler as a default. I would like to actually pass the real name. I tried to add header information as follow: context.Response.AddHeader("content-disposition", "attachment; filename=" + fileInfo.Name); And it works but I do not want the user to have to choose between open and save, i want the file to open normally

How to implement Content-Disposition: attachment?

社会主义新天地 提交于 2019-11-26 23:10:53
I am trying to make it so that mp3's on my site are downloaded by left clicking instead of having to right click and save as, So in order to do that, I have to set the Content-Disposition: attachment. This is my first website so I am new to how to actually do this, but do I do this in my html markup or do I set this somehow with my hosting site? Here is an example of what my markup looks like. <div class="download"> <a href="MP3/Morgan Page, Sultan & Ned Shepard, and BT feat. Angela McCluskey.mp3" <img src="img/dlicon.png"/></a> </div> Example of MP3 Lists: <a href="download.php?file=testing

Header Location + Content Disposition

拥有回忆 提交于 2019-11-26 22:05:04
问题 So I have a downloads page where you click a link, it opens /downloads/download/randomhash randomhash is found in the db, i increment a download counter, and then redirect to the actual file e.g. /uploads/2012/file.png. Everything works except for the redirect doing what I'd like it to do. I'm not sure why it's not working... header("Location: " . $row->uri); header("Content-Disposition: attachment; filename=$row->name"); On the first load of the file, it has the appropriate content

forcing a file download with php

烂漫一生 提交于 2019-11-26 22:02:17
问题 I know how to make the download occur, when the download happens it appends the html from the web page that causes the download. How do I filter out the HTML? 回答1: I understand that you're trying to output some stream for download from PHP page? If so, then don't output that content from the page that contains HTML, but redirect to separate php page that outputs only the download stream, with headers if necessary. 回答2: If I understand you correctly it's a common problem. I solved it by using

How to set response filename without forcing “save as” dialog

泪湿孤枕 提交于 2019-11-26 18:57:38
问题 I am returning a stream in some response setting the appropriate content-type header. The behavior I'm looking for is this: If the browser is able to render content of the given content type then it should display it in the browser window. If the browser doesn't know how to render the content, then it should display the "save as" dialog where the filename should be the one provided in the response. The problem is that if I set the Content-Disposition header with: "attachment; filename="myfile

Unicode in Content-Disposition header

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 17:00:45
问题 I am using HttpContext object implemented in HttpHandler child to download a file, when I have non-ascii characters in file name it looks weird in IE whereas it looks fine in Firefox. below is the code:- context.Response.ContentType = ".cs"; context.Response.AppendHeader("Content-Length", data.Length.ToString()); context.Response.AppendHeader("Content-Disposition", String.Format("attachment; filename={0}",filename)); context.Response.OutputStream.Write(data, 0, data.Length); context.Response

Force download of 'data:text/plain' URL

左心房为你撑大大i 提交于 2019-11-26 17:00:42
问题 I was wondering whether it is possible to force a browser (at least Chrome) to download a data:text/plain URL. Chrome does download binary URLs (e.g. data:application/zip;base64,... ), but it does not download files that can be viewed inside the browser (such as text files). What I already tried with no luck so far is this: data:text/plain;content-disposition=attachment;filename=test.txt;... But it seems like I cannot add headers like this. Is there any way to make Chrome download a data:text

Download textarea contents as a file using only Javascript (no server-side)

一世执手 提交于 2019-11-26 11:01:27
问题 I am being asked to make a \"download\" button that downloads the contents of a textarea on the same page as a file, with the browser\'s \"Save As...\" dialog showing up. Copy/paste would do the job just fine, but it is a \"requirement\". Right now, I am just posting the contents of the textarea to the server, which echos them back with Content-disposition: attachment slapped on. Is there a way to do this with just client-side Javascript? 回答1: This may be what you are looking for: http:/

Avoiding content type issues when downloading a file via browser on Android

北城以北 提交于 2019-11-26 09:29:11
问题 If I have a file made available to a browser through my webapp, I normally just set the URL to something like http://website.com/webapp/download/89347/image.jpg . I then set the HTTP headers Content-Type: application/octet-stream; filename=image.jpg and Content-Disposition: Attachment . However, on the Android. It seems the only way I can get the file to download is to set Content-Type: image/jpg . Otherwise the file name says <Unknown> and an error comes Download unsuccessful Cannot download