Hi,

we're using this approach, ...


HTH,

Regards,


Raimon Fernandez


<%

...

$docFileName:="fileName"

document to blob($path_doc;$blob_file)

if(BLOB size($blob_file)#0)

set response header("Content-Disposition"; "attachment; filename=" + $docFileName)

set content type("application/octet-stream")

SEt cache control("") ` Bug for IE on Windows, if the connection is SSL and NO cache/pragma and the file is a Pdf, doesn't work

write blob($blob_file; "application/octet-stream")


else


        $error_txt:="Error, something happened to the file "
        include("/error.a4d")

end if



...

%>




On 09/05/2006, at 8:08, Michael Check wrote:

We have successfully created code for uploading files to a site and
moving that file to an A4D-aware directory.  Now we want to download
it back to the user as a link.  Can someone give me some sample code
to do this?

I assume that we need to copy the file into a variable and send that
to the browser, but I'm not sure how to get started.

I've done this with PHP by using:

                $dir="download/files/";
                $filename = $_REQUEST["file"];
                $file=$dir.$filename;
        
                // Test to ensure that the file exists.
if(!file_exists($file)) die("I'm sorry, the file doesn't seem to exist."); // Extract the type of file which will be sent to the browser as a header
                $type = filetype($file);
                $size = filesize($file);

                ob_clean();                     //      clean the output buffer 
of any crap

                // Send file headers
//              header("Content-type: $type");
header("Content-Type: application/force-download; name=\"$filename \"");
                header("Content-Transfer-Encoding: binary");
                header("Content-Length: $size");
                header("Content-Disposition: attachment; 
filename=\"$filename\"");
                header("Expires: 0");
                header("Cache-Control: no-cache, must-revalidate");
                header("Pragma: no-cache");

                // Send the file contents.
                set_time_limit(0);
                readfile($file);
                exit;

But in a4D, I can't seem to get the file into a variable correctly.

Thanks!

Michael Check
_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/



_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/

Reply via email to