Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic include file from folder content

Status
Not open for further replies.

KarlZ

IS-IT--Management
Mar 4, 2003
5
0
0
SE
Hi,

I'm trying to create a page that reads files from a folder and includes them in the page itself. Not just the name of the file, but the content as is.

I'm not very good at this coding-thing, (if at first you don't succeed...) :)
I had to split the "include file"-codebit to make it work as far as this.

Tthe sourse-code of the page looks just the way it should, but the included page won't render.

I hope you understand what I'm getting at.

What I want is this:
Name of file printed <br>
File content showing (the file is a bit of code that may be both images and text)<br>

My research has lead me to understand that this approach might not be the best one since the "include file" must be processed earlier to show up.

Any suggestions, anyone?
help much appreciated!

/K

My code looks like this so far...

<%
Dim fso, fld, fil
Dim incl1Text, incl2Text, inclEndText
incl1="<!--#incl"
incl2="ude file="
inclEnd="-->"
Dim inclComplete
inclComplete=incl1 & incl2
Dim incl
Dim strBody

Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(Server.MapPath("../files"))
For Each fil in fld.Files
incl = inclComplete & """../files/" & fil.Name & """" & inclEnd

strBody = strBody & fil.Name & "<br>" & incl & "<br>"
Next
Response.Write(strBody)

%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top