How to show "Save As" window at download time?

Asked

Viewed 876 times

1

As low as the video that has the option to "save as", in php, already tried. it seems that something is missing, always download

index php.:

<form action="down.php" method="post" name="url">
<input name="url" type="text">
<input type="submit" value="Download">
</form>

down php:

<?php
if(!empty($_POST['url'])){
  $fileName = $_POST['url'];
    header("Content-Type: video/mp4");
    header("Content-disposition: attachment; filename=\"video.mp4\"");
    readfile('video.mp4');
    exit;
}else{
    echo 'O video não existe.';
}

1 answer

3

There’s no way, the dialog box Save as is a browser option of user choice, there is no way to force it to appear via scripts, nor scripts server-side and no scripts client-side (like Javascript).

There are browsers that download directly, for example mobiles there are browsers that show such dialog box to save by default, but the only thing you can do is provide a link with information saying:

Right click and select "Save as..."

Only in this way the dialog box appears without having to configure the browser

The user of a Desktop browser decides whether to download directly (usually to folder Downloads) or if you are shown the dialog asking where you want to save, for example, in Chrome if you navigate by typing in the address bar chrome://settings/?search=downloads, you’ll notice this:

configurar chrome

See that the option is disabled, if you enable this option whole and any download will have the dialog box asking if you want Open up or Save/Save the download and will not even need to right click mouse/mouse, if it is disabled will save directly in folder Downloads your system’s default (usually, but it is possible to change the folder’s location).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.