Anu
Anu

Reputation: 925

Downloading file after selecting folder not directly to downloads folder in PHP

I got one piece of code that, when I press the download button, the file get saved in the Downloads folder in my PC. Instead of that, I want to have a folder selection dialog and then to saving that file to that folder in D drive or another drive. How can I do that?

if(file_exists($dms->contentDir . $content->getPath())) {
    header("Content-Transfer-Encoding: binary");
    header("Content-Length: " . filesize($dms->contentDir . $content->getPath() ));
    $efilename = rawurlencode($content->getOriginalFileName());
    header("Content-Disposition: attachment; filename=\"" . $efilename . "\"; filename*=UTF-8''".$efilename);
    header("Content-Type: " . $content->getMimeType());
    header("Cache-Control: must-revalidate");

    readfile($dms->contentDir . $content->getPath());
}

Upvotes: 0

Views: 69

Answers (1)

Salketer
Salketer

Reputation: 15711

What you are asking is not possible. This is part of the user settings in the browser. You cannot make a webpage force different settings.

The only thing you could do is hint a filename, as I see you are doing. But that does not mean it will not be changed by the user during/after download.

Upvotes: 1

Related Questions