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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find file using wildcard

Status
Not open for further replies.

mfenn

IS-IT--Management
Sep 6, 2008
22
US
Hello,

Not sure if I have the correct forum for this.

We have a website where outside customers fill out a form that gets submitted to a SQL database, they can attach pdf or txt files to the data they are submitting. The attachments are stored in a folder on the webserver. Each submission has a unique id attached to it.

We also have a classic asp intranet page that displays the data that was submitted. I want to display a link on the asp page to any documents that were sent for a specific ID. I will always know the first 8 characters of the file name but will not know the rest of the file name or extension. There is a field that will tell me how many files were attached to the form. Here is my code:

Code:
<%
        if strAttach > 0 then
%>
        <a href="x:\'" & intMyID & "' & " - " & "?" ">  
<%
        else
%>
 	<td> No Attachment(s).  </td>
<%
        end if
%>
X is a mapped drive from the intranet webserver to the server where the files are stored. If there was more than one file submitted then there should be a link to each file. There are 2 files for the ID I'm testing.

an example file name would be: 31181 - L_Valdez.pdf
(unique 5 digit id space dash space filename)

Any help would be appreciated.
Thanks!
 
I think I have code similar to what you need but want to verify. You want to have a classic ASP page display links to documents but only if they contain the ID string in their name. Is that right? How are you identifying the ID within the ASP?

I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Mark,

You are correct. intMyID is the variable the ID is stored in and is the only part of the name that is known. This ID is assigned to the transaction when it is submitted by the user and is appended to the beginning of every attachment the user sends.

Does that answer your question?

Thanks,
 
Here you go, you will need to play with it. Change the directory name twice int he code to match your directory and add whatever you need to grab the intMyID. The code already has inMyID in it to check the file names for it.

Code:
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="The Spider's Parlor">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Customer Download Page</TITLE>
</HEAD>
<BODY>
<!--
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: [URL unfurl="true"]http://www.thespidersparlor.com[/URL]
' COPYRIGHT (c) 2004 All Rights Reserved
' DATE  : 3/16/2004
-->

<table height=100%>
<tr>
	<td bgcolor="84A5C6" width=17% height=100%></td>
	<td valign=top>
		
		<%

		
		set directory=server.createobject("scripting.filesystemobject")
		set allfiles=directory.getfolder(server.mappath("/downloaddirectory/"))
		
		' Lists all the files found in the directory
		For each directoryfile in allFiles.files 
			If Instr(directoryfile.name,intMyID) > 0 Then
				
			%>
			<a href=/downloaddirectory/<%
			' Write out the name of the document
			response.write server.urlencode(directoryfile.name) %>><% response.write directoryfile.name %></a><br>
		<% 
				
		' End for next loop to list documents
			End If
		next 
				
		%> 
		
		
	</td>
	<td bgcolor="84A5C6" width=17% height=100%></td>
</tr>
</table>


</BODY>
</HTML>

I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
I changed the /downloaddirectory/ to /X:/ and I get this error:
Server.MapPath(), ASP 0173 (0x80004005)
An invalid character was specified in the Path parameter for the MapPath method.

I also have a virtual directory in IIS that points to the location of the files. I'm using (server.mappath("/uploads/")) which gives me this error: Microsoft VBScript runtime (0x800A004C) Path not found.

Is there something else I need to do?
Thanks,
 
You can't use a mapped drive. You have to give it the name of the folder it really exists in. Server.Mappath("/uploads/") indicates a sub folder in the current web site called uploads.

Just as you would need to specify a directory using an IMG tag, you might need to alter the code such as "../uploads/".

I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
So if the files are on another server i can use \server\c\inetpub\folder\folder\uploads\? I've tried this and it still gives me the path not found error.

I'm trying to use the virtual directory setup in IIS but that's not working either. I've given "Everyone" full control of the share on both ends but I'm getting (HTTP Error 401.3 - Unauthorized: Access is denied due to an ACL set on the requested resource) when i try to navigate to it on the web.

Sorry, I'm pretty new to asp/vbscript.

thanks.
 
No, the files would be expected to be within the folder structure of the web site.

I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top