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

Passing File Paths

Status
Not open for further replies.

JezEling

IS-IT--Management
Mar 22, 2004
127
GB
Hi All,

I have been searching around to a solution to this problem but to no avail. My problem is this, I need to be able to give the user the ability to pick a file from the local file system via navigation and pass the path and file name of the selected file back to the ASP page. From here I can then write the path back to my database.

Can anyone offer any suggestions as how I may solve this?

Many Thanks

Jez
 
Hi Jez,

Some years ago I constructed a property web site + database. I designed a number of .asp pages to enable the site administrator to upload image and pdf files of property details and store details in a database - bits of this is what I think you are looking for. The web server supported 'persits' ASPUpload.

The process was in 2 steps - step 1: user browsed to select file to upload - step 2 the file was uploaded (using ASPUpload) and the name extacted for the database reference.

I can't illustrate all the code, but here are the important bits:

Step 1:

<FONT SIZE="2"><B>Instructions:</B>
Click on Browse.. to select an image file from your hard drive,
then click Upload Image.
Thumbnail, medium and large sized images will be created
and stored in the appropriate folders.
<P>

</FONT>
<FORM ACTION="UploadImageA.asp?NewsID=<%=ProdID%>&Item=<%=Itm%>&ImgID=<%=ImgID%>&imgname=<%=imgname%>&ImgStore=<%=imgstore%>&imgType=<%=lngType%>" METHOD="POST" ENCTYPE="multipart/form-data">
<TR>
<TH align="Center"><b>Step 2 Of 2</B></TH>

</TR>

<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="2">

<TR>
<TD BGCOLOR="#E1E1FF" ALIGN="CENTER"><FONT FACE="Arial" SIZE="2" COLOR="#000000"><B>Select an Image</B></FONT></TD>
</TR>
<TR><TD BGCOLOR="#EEEEEE" Colspan=2><INPUT TYPE="FILE" NAME="myfile" SIZE="50"></TD></TR>
<TR><TD BGCOLOR="#EEEEEE"><INPUT TYPE="SUBMIT" VALUE="Upload Image"></TD></TR>
</TABLE>
</FORM>

<P>

</TD></TR>
</TABLE>

</Body>

Step 2 (The POST)

Set Upload = Server.CreateObject("Persits.Upload")
Upload.OverwriteFiles = False
Upload.SetMaxSize 3000000, True

On Error Resume Next
Upload.SaveVirtual strFolder
If Err <> 0 Then
%>

<FONT SIZE="3" FACE="Arial" COLOR="#FF0000"><% If Err <> 0 Then Response.Write "An error occurred:" & Err.Description Else Response.Write "Nothing has been uploaded."%></FONT>
<P>
<FONT SIZE="2" FACE="Arial"><A HREF="NewsImagesEdit.asp?NewsID=<%=ProdID%>&Item=<%=Itm%>&ImgID=<%ImgID%>">Try again</A>.</FONT>

<%
Response.Buffer=False
Response.end
Else
On Error Goto 0
Set File = Upload.Files(1)
If File.ImageType = "UNKNOWN" Then
File.Delete
%>
<FONT SIZE="3" FACE="Arial" COLOR="#FF0000">This is not a valid image file.</B></FONT>
<P>
<FONT SIZE="3" FACE="Arial"><A HREF="NewsImagesEdit.asp?NewsID=<%=ProdID%>&Item=<%=Itm%>&ImgID=<%=ImgID%>">Try again</A></FONT>
<%
Response.Buffer=False
Response.End
Else

'Load into images Db
strSQL = "Select * From Tbls_Images WHERE ((Tbls_Images.IMG_ID)=0);"
Images.Open strSQL, jbacnn, adOpenKeyset, adLockOptimistic
Images.Addnew
Images("IMG_Name").Value=ImgName
'Bad File Patch 5/52003
Dim P_Tail, Temp_1, Temp_2
F_Name = Replace(File.ExtractFileName," ","_")
F_Name = Replace(F_Name,",","_")
F_Name = Replace(F_Name,":","_")
F_Name = Replace(F_Name,";","_")
F_Name = Replace(F_Name,"&","_")
P_Tail = Instrrev(F_Name,".")
Temp_1=Right(F_Name, Len(F_Name) - P_Tail + 1)
Temp_2=Left(F_Name, P_Tail - 1)
F_Name = Replace(Temp_2,".","_") & Temp_1
'End Patch

Images("IMG_ABS").Value="/Images" & ImgStore & "/" & File.ExtractFileName
Images("IMG_Size").Value=1
Images("IMG_Type").Value=lngType
Images("IMG_Width").Value=File.ImageWidth
Images("IMG_Height").Value=File.ImageHeight
Images("IMG_OPath").Value=Left(File.OriginalPath,255)
Images("IMG_DateAdded").Value=FormatDateTime(Date(),1)

I hope this gives you something to build on.

Regards

Ian


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top