Wednesday, 15 January 2014

html - Chrome file download name incorrect -



html - Chrome file download name incorrect -

i have next line <a id="export" href="data:text/plain;base64,mdow" download="fname">download</a>

i'd expect save file fname.txt, however, chrome saves download.txt. tested on firefox, gives expected behavior fname.txt.

this suggests behavior intentional , won't fixed, question is, there way download right filename?

it's not security concern

the pseudo specification says:

the attribute can furthermore given value, specify file name user agents utilize when storing resource in file system. value can overridden content-disposition http header's filename parameters. [rfc6266] in cross-origin situations, download attribute has combined content-disposition http header, attachment disposition type, avoid user beingness warned of perchance nefarious activity. (this protect users beingness made download sensitive personal or confidential info without total understanding.)

sure if browser detects header go against yours, not utilize definition.

which not case...

you have bad formated base64 text:

this should work.

<a id="export" href="data:text/plain;base64,mdow" download="fname.txt"> download</a>

and seek diferent encoding if need expanded charset utf-8, utilize iso-8859-1 insted

example 2

<a download="fname" href="data:image/jpeg;base64,/9j/4aaqskzjrgabaqaaaqabaad/2wceaakgbwghbgkibwgkcgkldrypdqwmdrsucrakib0iiiadhx8kkdqsjcyxjx8flt0tmtu3ojo6iys/rd84qzq5ojcbcgokbqufdgufdiszexkrkysrkysrkysrkysrkysrkysrkysrkysrkysrkysrkysrkysrkysrkysrkysrkysrk//aabeiadaamambigaceqedeqh/xaazaaacaweaaaaaaaaaaaaaaaafbgmebwd/xaaseaabbaibagudbqebaaaaaaabagmebqyriqaubxitijevfjixqvgbkwez/8qafaebaaaaaaaaaaaaaaaaaaaaap/eabqraqaaaaaaaaaaaaaaaaaaaad/2gamaweaahedeqa/ahxk8lysnmjo8fne0y1u/ux37x1etibdhqr3ipaa0er/ppqzzl807gdkh2vh/p7kk5kdzhsxnzpbogyqar+uddzhxzu5f/uwzizlcfa73dnyrt018nru4w8oaen/ahjnqpsnjwpxcvg5nkmzvjmruakvfazhwixjviuaqacbv8dcc7i6dqmlztkq6jxm5hjh24du1fbdvn9uelyupkiokk0loafjji5+ep6tj80do8gubeltih18wsqipht4dzibsficsvhs2fdelagn9uolckqsq8lkwmmwjmwzgp2lbpkpceexysfiw4ccq1txja/b56tcptr+hr5zivuv14bffmlrjky4r1i6upbqwvkoiwqcu6gv46brby/noxgyplr4fwo9itymmzsl5qt26xsegq/rjjyprnfmlystmio8gne6y7u/uwh6r1fnlblgqn3lpii2eb/hpww5lj8xkoomyoevyzf7aiixxwztiesuyegkgga6/lxpowennchiv6i1kwhyqp/zyc1fdehph2n3chkggef7zo6i6al4jb2nkda/ipmcsk2dmj1zjk6ixbddi1qj8pptcqn4+eseohmac05kd9cxjweqrykoq7gsgoamfiyhektsxpxsoj9y0jkdnqfxopwrxi0ln5ffqgwk4owyrlmi7ovurx6bxqqfbokezpu44+olythol9s7tocwazah6tfgw5tbsluee+yhx/qfjycpyoa6c94lutu6qrptxf18k+vutrlv8kag4myq8qz6cdti87gwshke/baa+ehr139bnvcr6w9zefe2qp0ur/wjjyenfbvdy93gln/lo/hvhknb+uyqnnw9rwsocmazbiskkm4um1hu4sgxvk4tiabkncafoh1vrcuumzhkyti2yjrzcnbyw7ncbbt3q167pskisfbktpz8gd9bp2fnyhkooo2m3fkmvegqlfimtwstnnteispw870ken8tea56i439a+6l/a/2l2fyhz/tft+udx6g3vycelry/wdfnrrma+l6uk3ufrlys4dh69jcjx7pexsbfxsbdehpwvzdhabslfweixgvj7tvmproql2eyqk8klyzilto2vqnlqboh7ddghng9azzdul+otnkmv8kf2whoymmzradjdwh5rbip+caoiekbgsgi5vbyalmxxgyvbuuqu09crgismqkaagknx5b452b1qwv41kknmtey+kj1l2p+npswvqkaw2xctxtqoqrocn+eogzmizp2m6ldqvd+b3svyk69cjpnse3wneahp8afoxsdoa1rmungpdmeitwqhimvljjsawstmoibcvo5+cuhhuo/j53rqs5g4rc5uqldvwbwzztflr1nmafry9c46qw4hgymqknbatsae9xsq8pc0synpbql5mldju7mgxh7x5ez2qkelplsnskkednkgcjq1x+ezter49yyo1js1vdgdiyokov3rsworvthusr8nhr4+ogbrffbtyuh1djuzbjmxdsrosijcnq6lzel6rjqfc3lqobrvrygkh/aj03yilx73ktzmnrj8ofaxdagx7bbtl7hu6dknnj1de1ahrk610quee+vfe865h3jmchnnuooqhs3wrl6ct3zfiirrza/ykjyhtx4eyx9q/vxjhzltjm95xqcr32sq5xl0lxwpbktp8xa42d9b//2q==" >image code</a>

note: ".txt" extension @ download attribute not necessary practice

edit2: tested in 37.0.2058.2

fidle: http://jsfiddle.net/yl8uz/

html google-chrome

No comments:

Post a Comment