Wednesday, 15 August 2012

Javascript download attribute not working when saving image dataUrl -



Javascript download attribute not working when saving image dataUrl -

i using chrome.

this code.

var save = document.createelement('a'); save.href = fileurl; save.download = filename; alert(save.download); save.click();

it works doesn't alter image name. saves "download.png".

what wrong?

it help see fileurl , filename set guessing problem. in firefox , chrome have utilize relative path image. not work on remote images.

mdn says:

in firefox 20 attribute honored links resources same-origin.

i have tested in chrome , firefox , works if utilize relative path image:

save.href = "images/wonky-download-121938718712348891912.jpg"; save.download = "coolname.jpg";

i ralative path because using mysite.com/image.jpg didn't work while image.jpg did.

update

whatwg.org says:

in cross-origin situations, download attribute has combined content-disposition http header, attachment disposition type, avoid user beingness warned of perchance nefarious activity.

javascript download data-url

No comments:

Post a Comment