Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
162 views
in Technique[技术] by (71.8m points)

html - Why does a .cpp file get wrong extension while downloading with data download anchor?

I have the following HTML code:

<a href="data:text/x-c;charset=utf-8,struct%20example%20%7B%0A%09int%20number%20%3D%205%3B%0A%7D%3B"
   download="example.cpp" target="_blank">Download a struct stub</a>

but for some reason, clicking this anchor results downloading an example.cp file and not example.cpp. I think I've checked everything. For instance, for .json files it works correctly. Also text/x-c is the right Content-Type for .cpp files. I've also tried with text/plain, but it still kept getting changed to .cp. Why does this happen and is there a workaround to it? I'm using Google Chrome.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...