dongzhou4727 2018-08-26 18:28
浏览 71

如何在Safari浏览器中强制下载PHP

I trying to get my code to force the download of Video and Audio files on my server. It downloads like I want it to in Chrome but when I do Safari the person has to Right click an download. I know it can be done for Safari cause I have been to sites that starters the download on my computer. Can anyone help me with this code. I want people to be able to download the file but only once. When it is done in Safari it takes me to the webpage for the file and I don't want it to be able to be copied and pasted. So I have it open in a blank page but it still shows in the history.

<p>Select video to upload:

<button onclick="openWin()"; disableButton(btn1) type="button" id="btn1">Click here to download file.</button>
<button onclick="closeWin()">Click here after file downloads.</button>

<script>
var myWindow;

function openWin() {
    myWindow = window.open("http://website/subfolder/audio/musicfile.mp3", 
            "_blank", 
            "width=500, height=500");
}

function closeWin() {
    myWindow.close();
}

Does anyone know how to correct this or have another way that I can get it done securely? I thank everyone for their assistance.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 vmware exsi重置后的密码
    • ¥15 易盾点选的cb参数怎么解啊
    • ¥15 MATLAB运行显示错误,如何解决?
    • ¥15 c++头文件不能识别CDialog
    • ¥15 Excel发现不可读取的内容
    • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
    • ¥20 yolov5自定义Prune报错,如何解决?
    • ¥15 电磁场的matlab仿真
    • ¥15 mars2d在vue3中的引入问题
    • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面