Force File Download

Viewing 6 posts - 1 through 6 (of 6 total)
#170791

John
Member

Firefox browser allows the user to set how a PDF file will be handled: Download, Open, Ask.

I want to override the user setting and force a download using HTML “Content-Disposition: attachment”.

How can I implement this for a file stored on Google Drive?

#170797

Tanvir
Spectator

Hello,
Hope you are well.
Could you please share related website link to check the issue properly.
However, If you are using remote url then download or open in browser will not depends on wpdm pro, If you want to force download, you need to upload it with wpdm pro or use server file browser to attach file.
Thanks

#170825

John
Member

I just tested and it does not matter where the file is located (server or Google Drive). Firefox browser allows the user to specify how they want to hand specific file types (Open in Firefox, Always ask, Save file).

View post on imgur.com

This behavior can be overridden using the “Content-Disposition” HTML property.
See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition

Is there a way to tell wpdm to use the “Content-Disposition” HTML property?

#170837

Tanvir
Spectator

Hello,
We have already content-deposition set for audio/video files. You can find it in download-manager-master\src\__\FileSystem.php
However, you can modify that also you can do it using javascript for this.
Thanks

#170838

John
Member

I looked at download-manager-master\src\__\FileSystem.php and it says “DO NOT CHANGE”. Any changes I make will be over written by a plugin update.

I would like a more detailed explanation of what you are suggesting.

#170892

Tanvir
Spectator

Hello,
If you want the user to be prompted to save the data you are sending, such as a generated PDF file, you can use the » Content-Disposition header to supply a recommended filename and force the browser to display the save dialog.

header("Content-Type: {$filetype['type']}");
 header("Content-disposition: attachment;filename=\"$filename\"");

You can also check this

Adding this codes in functions.php will work fine. But before that please make sure if firefox do the downloads as you want. for that you can manually try to add any pdf file and add that code manually without any php variable.

However, If you want to force download, please always attach the file using the server file browser or upload directly using wpdm.

Thanks

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Force File Download’ is closed to new replies.