Chrome Extension

Download file from remote url to user desktop in PHP

<?php
    $file_url = $_GET['file_url'];
    $file_name = basename($file_url);
    header('Content-Type: application/octet-stream');
    header("Content-Transfer-Encoding: Binary");
    header("Content-disposition: attachment; filename=\"".$file_name."\"");
    readfile($file_url);
    exit;
?>
We are a bunch of lazy programmers so we developed this chrome extension
search code from your favorite search engine
Install Now

To download a file on a user desktop from a remote URL in PHP, you can use this code snippet. We are using readfile() PHP function for that and also Content-disposition header which is required to download the file.

Search Index Data (The code snippet can also be found with below search text)

Save file from url to user system PHP
Was this helpful?
0 Comments
Open Code Manager We are hiring