How to make download link for the attached file

Permalink 1 user found helpful
Hi I working in web application, In my task is: to attached the file (.txt and .pdf) and to store in the mysql db.

the file was attached in this code
<?php echo $form->file('teFA'); ?>


Now how to download a file from db. I dont know how to achieve this please suggest to me......


thanks
Kumar

 
sgelinas replied on at Permalink Reply
First the file must be in the file manager. If you upload your file without the file manager you must import the file
Loader::library("file/importer");
$fi = new FileImporter();
$resp = $fi->import($filePath, $fileName);
if (!($resp instanceof FileVersion)) {
    // upload error
    $errmsg = $fi->getErrorMessage($resp);
} else {
    unlink($filePath);
}

Then just use the File block to display your file.

Hope this help !