473,324 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Need a solution

Jim
Hi,

Background:

After a member registers, he's able to access and download any file
available. We want to avoid the end user being able to distribute an URL
to these files thereby making it simple for other users to download them.

Solution I'm working on:

I have a variety of files (html, pdf, doc, xls, and others) sitting
outside my "wwwroot" folder. I have an ASP script which checks the MIME
type for the given file and now, my problem is, how do I use the
FileSystemObject to grab those files and display them to the user?

Let's suppose the user is requesting demo.html. I use the FSO to open
the demo.html in the folder outside the wwwroot, and then set the mime
type and then what do I do? Response.write? What about binary files
which need to trigger a download action?

Thanks,
Jim
Jul 19 '05 #1
1 1431
Jim wrote on 26 mrt 2004 in microsoft.public.inetserver.asp.general:
After a member registers, he's able to access and download any file
available. We want to avoid the end user being able to distribute an
URL to these files thereby making it simple for other users to
download them.

Solution I'm working on:

I have a variety of files (html, pdf, doc, xls, and others) sitting
outside my "wwwroot" folder. I have an ASP script which checks the
MIME type for the given file and now, my problem is, how do I use the
FileSystemObject to grab those files and display them to the user?

Let's suppose the user is requesting demo.html. I use the FSO to open
the demo.html in the folder outside the wwwroot, and then set the mime
type and then what do I do? Response.write? What about binary files
which need to trigger a download action?


[expecting: session("loggedIn") = true]

html files sh/could be renamed to asp files, put in to the root tree and
headed as:

<% if not session("loggedIn") then server.transfer "/404.asp" %>

=================

or stay where they are and be accessed by a same-named asp file
"theFile.asp" containing:

<%
if session("loggedIn") then server.transfer path & "theFile.html"
server.transfer "/404.asp"
%>

==================

other files can be accessed by a same named asp file like
"mydoc-doc.asp"

<%
if not session("loggedIn") then server.transfer "/404.asp"

Response.Clear

strFileName= path & "mydoc.doc"
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open

objStream.Type = 1
objStream.LoadFromFile strFilePath

Response.AddHeader "Content-Disposition", "inline;"
'' is this right ????

Response.ContentType = "application/MSWord" ' OR ....
Response.BinaryWrite objStream.Read
Response.Flush
objStream.Close
Set objStream = Nothing

%>

not tested as such.
Guru' are invited to improve on this in a follow up
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jani Yusef | last post by:
I have a HW problem stated as shown at the top of the solution. The thing is is that I am not 100% sure wtf constant memory means. Well, I think I do but I am confused. Does my solution use contant...
16
by: Joel Finkel | last post by:
Folks, I am confused as to how to implement the following solution. I have a series of processing steps, each of which contains similar features (forms, etc). Therefore, I create a base...
6
by: SP | last post by:
Hi, I want to add wait cursor code whenever page is post back. Page may be post back on my user control's or on change of dropdown or on click of any button on page. so is there any common...
2
by: moondaddy | last post by:
I'm building a small POS system which I'm going to license out and need to include credit card processing. I've build eCommerce sites before and custom coded CC processing for verisign, but that...
20
by: Tony | last post by:
I have a situation where I want to send data, but I have no need for a response. It seems to me that XMLHTTPRequest is the best way to send the data, but I don't need any response back from the...
23
by: vinod.bhavnani | last post by:
Hello all, I need desperate help Here is the problem: My problem today is with multidimensional arrays. Lets say i have an array A this is a 4 dimensional static array.
1
by: VB Programmer | last post by:
Here's the scenario: 3 different pcs in a doctors office. 2 doctors with 2 seperate appointment calendars. All 3 pcs need to be able to see, real time, both doctors calendars and add, remove,...
10
by: Frank | last post by:
I've done this a few times. In a solution I have a project, Say P1, and need another project that will contain much code that is similar to that of P1. I hope no one gets hung up on why I...
25
by: Jon Slaughter | last post by:
I have some code that loads up some php/html files and does a few things to them and ultimately returns an html file with some php code in it. I then pass that file onto the user by using echo. Of...
7
by: MZ | last post by:
Hello, I have a webcam connected to the Internet. I can access the current static picture of the camera using an url link. It shows the picture with high resolution 1600x1200. I would like to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.