我们可以使用二进制写入javascript来编写图像文件 [英] can we use Binary write in javascript to write image file

查看:60
本文介绍了我们可以使用二进制写入javascript来编写图像文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的处理程序文件中有这个代码,它将文件的二进制内容写入浏览器并允许用户查看/下载/保存它。

我有一个要求,我想写图像文件到浏览器,使用HTML5画布创建图像文件,并使用canvas的toDataURL()方法检索图像数据。是否有任何方法可以使用类似于我现有的c#代码的javascript将此数据写入浏览器

I have this code in my handler file which write binary content of file to browser and allows user to view/download/save it.
I have a requirement where i want to write image file to browser ,image file is created using HTML5 canvas and the image data is retrieved using toDataURL() method of canvas. Is there any way to write this data to browser using javascript something similar to my existing c# code

private void WriteFile(byte[] content, string fileName, string contentType, HttpResponse response)
       {
           response.Buffer = true;
           response.Clear();
           response.ContentType = contentType;
           string extension = System.IO.Path.GetExtension(fileName);
           if (extension != ".htm" && extension != ".html" && extension != ".xml")
           {
               response.AddHeader("content-disposition", "attachment; filename=" + fileName);
           }
           response.BinaryWrite(content);
           response.Flush();
           response.End();
       }

推荐答案

经过一番谷歌搜索后,我看到了这个link ,我希望它有用。
After a little googling, i saw this link, I hope it;s helpful.


这篇关于我们可以使用二进制写入javascript来编写图像文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆