Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change file download name in iframe?

Tags:

html

My iframe tag look like bellow

<iframe width="100%" height="100%" src="'+file_url+'" frameBorder="0"> <p>Your browser does not support .</p></iframe>

file_url = store/ASDFVASDFADSFACASDFCDDF.doc

file_name = my word.doc

when i click on the iframe open link file download with incorrect file name.(doc file download with ASDFVASDFADSFACASDFCDDF.doc file name). how can i download file with real file name using iframe?

like image 345
Duleep Avatar asked Sep 16 '25 06:09

Duleep


1 Answers

The iframe element can't do that, but you could put this in a .htaccess file in the 'store' directory :

<FilesMatch ".doc$">
Header set Content-Disposition "attachment; filename=myword.doc"
</FilesMatch>

Note that I'm assuming Apache here, but most webservers have a similar function

like image 65
Tom van der Woerdt Avatar answered Sep 17 '25 21:09

Tom van der Woerdt