• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 802
  • Last Modified:

Open file in iframe but file name format isn't standard

Ok I have a vbscript running that takes a session id and finds a folder on a server that has an htm file in it I want to show in an iframe. Works great except the people saving the files have not always saved under the same name format. The file could be "adr 200000.htm" or "adr # 200000.htm" or "adr#20000.htm" etc.... It always will start with "adr" and end with htm. I'm not sure who to handle that. From here on in I can set a standard, but I need to handle the old ones.
say my adr is 200001

Folder path is \\server\folder\200000-200999\200001\

file could be "adr 200001.htm" or "adr # 200001.htm" or "adr#200001.htm"

My code rigth now is
<%
path= "\\server\folder\"
adr = left(session("adr"),3)
path=path & adr & "000-" & adr & "999\" & session("adr") & "\adr " & session("adr") & ".htm"
%>
<iframe src="<% = path %>" width="789" height="1819" ></iframe>

I'm just not sure how to handle this...
0
t1clausen
Asked:
t1clausen
  • 5
  • 3
1 Solution
 
John_LennonCommented:
if you know in what folder search, you can check all the files in that folder and see if it match your criteria, something like this

path= "\\server\folder\"
adr = left(session("adr"),3)
path=path & adr & "000-" & adr & "999\" & session("adr") & "\"

Set fso = CreateObject("Scripting.FileSystemObject")
Set ofolder=fso.getfolder(path)
Set oFiles=oFolder.files
for each f in oFiles
  if left(f.name, 3) = "adr" and right(f.name, 4) = ".htm" and instr(f.name, session("adr")) > 0 then
    'f.name is something like this: adr__session("adr")__.html (___ can be anything)
    strPage = f.name
    exit for
  else
    'f.name dosn't start with adr or dosn't finish with .htm or dosn't contain session("adr")
  end if
next
set oFiles = nothing
set oFolder = nothing
set FSO = nothing

%>
<iframe src="<% = path & strPage %>" width="789" height="1819" ></iframe>

'#################
see if that works
0
 
t1clausenAuthor Commented:
This looks good, but for some reason I just keep getting path not found errors. I hard coded a path in and still the same error? Any ideas?
0
 
t1clausenAuthor Commented:
The error happens on this line...

Set ofolder=fso.getfolder(path)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
t1clausenAuthor Commented:
I took out everything except.

<%
path= "\\server\folder\"
adr = left(session("adr"),3)
path=path & adr & "000-" & adr & "999\" & session("adr") & "\"
%>

<iframe src="<% = path & strPage %>" width="789" height="1819" ></iframe>

and this opens the folder the files are in so I know the path is right.


 
0
 
John_LennonCommented:
i'm not sure, but maybe getFolder dosn't suport "virtual" paths like \\server\folder, let me search for it
0
 
t1clausenAuthor Commented:
The only thing I can find is something about a permissions error, but I can open the file and view the folder fine.
0
 
John_LennonCommented:
maybe IIS dosn't have permission, it's diferent the permission you get as a user in your computer, and the permission you need in IIS to acces folders and files, check you config in IIS and see if it say somethign about rights
0
 
t1clausenAuthor Commented:
It looks right to me. I think it's because I'm going to a remote server that happens to be a domain controller. I'll try some oever folders and see how that goes. Thanks!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now