Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
download file without it being stored on server
  • Hi,

    Is there a way to download a file without that file being on the server?

    The issue is I have a dataurl (64bit) from a canvas stored in my database. Instead of first creating a file, storing it on the server, and then downloading it.... I would like to skip the storing part and download the contents immediatly.

    Is that possible?
  • There is no ready-made function of it.

    Best option will be is to see how File::download is implemented, and copy that, replacing the file read loop with your string data.
  • Just try to solve your problem. 
    You can create a "bridge" file just to act like download the file.


    Create a form and submit the dataurl to download.php.

    Store the download.php in public folder:


    $data = $_POST['data'];
    //removing the "data:image/png;base64," part
    $uri =  substr($data,strpos($data,",")+1);


    header('Content-type: image/png');
    header('Content-Disposition: attachment; filename="wow.png"');


    echo base64_decode($uri);
    Just for your reference only. This code has no security check, auth check, etc.


    If the canvas is on the web browser, you can try the download attribute to download the file on the client side. So you don't have to upload it to server and download again.

    <a href="data:image/png;........" download="filename.png">download</a>


    Unfortunately, Google Chrome is the only browser support this.


Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion