how to download document (file name) from grid other than original field

hi, i have field document (file name) where looks ugly in grid long link with full name, i want to get rid of that and display only small icon so user clicks on it to download the file… there is no such option, and couldn’t create custom field where to customize the link correctly… any idea or hint?

hi and thanks for this, i get an error

Error
Undefined variable: folder
Error
Undefined variable: domain
Error
Undefined variable: file

Well Mike $ variables are standard php variables. You have to assign them first with the required info :wink:

Obviously the variables $folder $domain $file
Must contain the correct value and must be set to onrecord.

well guys, albert and marcosc, tell me how or what to do :slight_smile:

albert, i know what you mean, it doesn’t work in development! it actually stores the files in http://127.0.0.1/scriptcase/file…older/File.PDF

can you post or send messagge with your code??

{download} is an HTML image field


$domain='localhost' ;
$folder='pdffiles' ;  //this is the folder indicated from the from the form application for uploading the files there
$file={file_pdf}; // this is the document file (file name), not database

$xcat =$file;
sc_link({download},"$xcat", ,"Download","_blank");


try this


$domain='http://localhost/' ;
$folder='pdffiles/' ; //    ### You have to add all path es: scriptcase/doc/file/ ##
$file={file_pdf}; // this is the document file (file name), not database

$xcat =$domain.$folder.$file;
sc_link({download},"$xcat", ,"Download","_blank");

hi i have been trying many things so far, without luck

here is the colsest one, i’m working on development enviornment



$domain='../../file' ;   //dev
//$domain=           //prod
$folder='doxfolder ;
$file={myfileurl};

$xcat =$domain.'/'.$folder.'/'.$file;
sc_link({myfileurl},"$xcat", ,"Download","_blank");

The issue with this that says not found although the path is ok in the broswer, but it addes a slash after the file name!! like

http://127.0.0.1:8088/scriptcase/file/doxfolder/File%name%20Pain-Seidel-160-3.pdf/

noticed the last slash in the file? then doesn’t work – i manually removed the slash from the link, it works

any idea?

hey guys, any hint please… I’m almost there, only the extra slash is standing now

$file={myfileurl};
echo $file;
What it shows??