Magento – File Download in CMS Page Broken – How to Fix

cmsdownloadable

This is a lame question, I know, but for some reason I can't get my href link to download the file properly in a cms page. I have some text, then a table, and inside one of the table cells is a link to download a file but it throws me to a 404 Not Found page. I've changed the link a couple times but can't seem to get it to work properly. Any ideas on why this is not working or why the wysiwyg removes my download="file.pdf" link?

<a href="{{media url='downloadable/file.pdf'}}" target="_blank" download="file.pdf">Download File</a>

I have also tried:

<a href="{{store url='media/downloadable/file.pdf'}}" target="_blank" download="file.pdf">Download File</a>

so the 'download="file.pdf"' gets stripped out as soon as I save my changes, so I guess the wysiwyg doesn't like html5 tags yet. But although the url is correct when I inspect it on the frontend it doesn't download the file.

~===== Answer =====~

Ok so it wasn't an issue with my link being in a cms page but rather the file location & permissions. I had my permissions set to 775 and upped them to 777 on the folder downloadable & the file itself, but for some reason moving the file to the media folder and using the following worked just fine:

<a href="{{media url='file.pdf'}}" target="_blank">Link</a>

I changed the permissions back to 775. Not sure why it didn't like being in a sub-folder.

Best Answer

Your download attribute support only in chrome and Mozilla browser. and that contain only (.img, .pdf, .txt, .html, etc.). This is new attribute OF HTML 5 But Magento WYSIWYG Editor will not provide so it will automatically truncate when you try to save cms page.

Related Topic