Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Show private files with a CGI application.

Posted on 2001-06-19
2
Medium Priority
?
167 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
[X]
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
2 Comments
 
LVL 8

Accepted Solution

by:
TOndrej earned 225 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

636 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