Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Show private files with a CGI application.

Posted on 2001-06-19
2
158 Views
Last Modified: 2010-04-04
I am looking for a solution to show files in private (not webserver public) directories on the web via a CGI executable. I tried it with a filestream it will work, but the browser can't recognize the filetype. For example:

c:\mywebserver\wwwroot is the location of my public files. I will give a user access to a file named: c:\test.pdf. The user have to call within it's browser my Delphi application getfile.exe:
http://mywebserver.com/cgi-bin/getfile.exe?file=c:\test.pdf&password=xxx
My application will load the file in a filestream and send the content of the filestream to the client. The data is OK. But IE don't understand that this is a pdf file and ask to download it and write it on disk with a strange name such as getfile.htm. If I choose to open it from the current location I will see the binary stream in my browser what I don't want.
0
Comment
Question by:snoei
2 Comments
 
LVL 8

Accepted Solution

by:
TOndrej earned 75 total points
ID: 6207434
I think you should set the content type to 'application/pdf'. See TCGIResponse.ContentType property.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6207482
This should work when the client has Acrobat Reader installed:


var fs: TFileStream;
begin
  fs := TFileStream.Create('pdffile.pdf', fmOpenRead);
  try
    Response.ContentType := 'application/pdf';
    Response.ContentStream := fs;
    Response.SendResponse;
  finally
    fs.Free;
  end;
end;
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question