Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set file download name #26

Open
chrillewoodz opened this issue Jan 22, 2018 · 2 comments
Open

Set file download name #26

chrillewoodz opened this issue Jan 22, 2018 · 2 comments

Comments

@chrillewoodz
Copy link

Would be great if you could set the name of the file you're downloading.

@Nodws
Copy link

Nodws commented Mar 22, 2018

try

var dataString = canvas.toDataURL("image/png");
var link = document.createElement("a");
link.download = 'image.png';
link.href = dataString;
link.click();

@MissMin
Copy link

MissMin commented Jun 21, 2018

中文:
楼上 @Nodws 老铁的代码是可行的。
打开canvas2image.js 第46行,修改saveFile()函数

function saveFile (strData) {
    var link = document.createElement("a");
    link.download = 'image.png';
    link.href = strData;
    link.click();
}

English:
The code from @Nodws is ok.
Open the canvas2image.js line 46. modify the saveFile()

function saveFile (strData) {
    var link = document.createElement("a");
    link.download = 'image.png';
    link.href = strData;
    link.click();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants