2 Replies Latest reply on Jan 12, 2011 1:17 AM by linrsvp

    How to download a file from database

    linrsvp

      Hi,

      My flex application contains a form that uploads a file into the server. This file is however saved in the database, and not on the disk. Most of the tutorials in the database explains how to download a file by passing the file's url to the "download" function of the fileReference Object. That dsnt work for me as my file is saved in the database.

       

      How do I download this file from the server ?

       

      For example, in php, we would do smthing like this :

       

      $content = $file_to_download['content'];
      $size = $file_to_download['content_size'];
      $type = $file_to_download['content_type'];
      $name = $file_to_download['filename'];

       

      header("Content-type:$type");
      header("Content-length:$size");
      header("Content-Disposition:attachment;filename=$name");
      header("Content-Description:PHP Generated Data");

       

      echo $content;

       

      When executing this file, it opens up the "download file" dialog box. How do i get the same effect in flex 4 ?