make a link to a open a "save as" dialog instead of the image opening in a new window.
  • I would like a link to an image structure make the user download the image instead of the default result which is opening it in a new window.

  • 4 Answers sorted by
  • Vote Up0Vote Down KevinKevin September 2010

    Use the <v:file> tag: http://docs.vaeplatform.com/v_file

  • The problem with that is I need to use the imagesize attribute to specify a crop size.

    Does the Vae sever allow for php header() functions to be used? I was thinking of trying something like this (for a jpeg)

    The url would be
    http://0.0.0.0:9999/downloader.php?file=http://ajaffe.vaesite.com/__data/a1b0ec43fb0eb3acec34c9cd28f6a88f.jpg


    <?php

    $file = $_GET['file'];

    echo $file;



    if(!file_exists($file)))
    {
    die('Error: File not found.');
    }
    else
    {
    // Set headers
    header("Cache-Control: public");
    header("Content-Description: File Transfer");
    header("Content-Disposition: attachment; filename=$file");
    header("Content-Type: image/jpg");
    header("Content-Transfer-Encoding: binary");

    // Read the file from disk
    readfile($file);
    }
    ?>

  • Vote Up0Vote Down KevinKevin September 2010

    You could certainly do this. You might need to call this function at the top of your script to ensure that Vae doesn't mess you up:


    vae_disable_vaeml();


    That will prevent Vae from trying to touch your output in any way.

  • It worked! For reference:


    <?
    vae_disable_vaeml();

    $filename = $_REQUEST['file'];
    $img = array_pop(parse_url($filename));

    header('Content-disposition: attachment; filename=' . $filename .'');
    header('Content-type: image/jpg');
    readfile($filename);

    ?>

Howdy, Stranger!

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

Sign In Apply for Membership

In this Discussion