Vely logo Empower C
install     tutorials     examples     documentation     license     about

11.0.11 released on Jul 25, 2022



Send file to client.


send-file <file> [ headers \
    [ content-type <content type> ] \
    [ download ] \
    [ etag ] \
    [ file-name <file name> ] \
    [ ( cache-control <cache control> ) | no-cache ] \
    [ status-id <status id> ] \
    [ status-text <status text> ] \
    [ custom <header name>=<header value> [ ,... ] ]


When a client requests download of a file, you can use send-file to provide <file>, which is its location on the server, and is either a full path or relative to the application home directory (see vv). Note however that you can never use dot-dot (i.e. "..") in <file> - this is a security measure to avoid path-traversal attacks. Thus the file name should never have ".." in it, and if it does, the program will error out and stop.


The following are subclauses that allow setting any custom header:


To send a document back to the browser and show it, use send-file with the "show" clause:
send-file "/home/vely/files/myfile.jpg" headers content-type "image/jpg"

An example to display a PDF document:
char *pdf_doc="/home/mydir/myfile.pdf";
send-file pdf_doc headers content-type "application/pdf"

If you want to send a file to the client for download (with the dialog), use "download" clause. This way the document is not displayed but the "Save As" (or similar) window shows up, for example to download a "PDF" document:
send-file "/home/user/file.pdf" headers download content-type "application/pdf"


Web ( out-header   send-file   web-call   silent-header  )  SEE ALL (documentation)

Copyright (c) 2022 DaSoftver LLC. Vely is a trademark of Dasoftver LLC. The software and information herein are provided "AS IS" and without any warranties or guarantees of any kind. This web page is licensed under CC-BY-SA-4.0.