Author |
Topic |
|
asp_storm
Average Member
USA
787 Posts |
Posted - 24 August 2001 : 14:09:31
|
i am writing a picture upload script and was wondering how you would display an image out of a database. i can display text fine. any help id
greatly appreciated! p.s. herez what i have so far:
<% Response.Write "<html>" & vbCrLf & _ "<head><title>Test DB Script</title></head>" & vbCrLf & _ "<body>" ' <--- Your code was missing this for sure....
Set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "D:/Database/pics.mdb" Set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select ID, Pic_Id, Pic_Taker, Pic_Other, Pic_Url from pic", conn ' Check for EOF or BOF first If rs.EOF or rs.BOF then ' Do nothing - no records found else Do until rs.EOF For Each x In rs.Fields Response.Write x.name & "=" & x.value & "<br />" & vbCrLf Next rs.MoveNext Loop end if rs.close set rs = nothing
conn.close Response.Write "</body>" & vbCrLf & "</html>" & vbCrLf %>
¦_____________Creator___Of___________¦ [-------------Newschoolskiing.com-------------]
Edited by - asp_newbie on 24 August 2001 14:10:10 |
|
JohnIII
New Member
United Kingdom
52 Posts |
|
james1415
Starting Member
1 Posts |
Posted - 24 August 2001 : 17:44:24
|
What I do is put the <IMG SRC=theimage.jpg> Just put the code and put where the image is. It works for me...
|
|
|
asp_storm
Average Member
USA
787 Posts |
|
asp_storm
Average Member
USA
787 Posts |
Posted - 28 August 2001 : 13:33:28
|
ok, i tried this:
<% Set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "D:/mysites/db/Database/gallery.mdb" '--- %> <% Set rs = Server.CreateObject("ADODB.recordset") rs.Open "Select Pic_Url from Pictures", conn %><table border="1" width="100%"> <%Do Until rs.EOF%> <tr> <%For Each x In rs.Fields%> <td><img src=<%=x.value%></td> <%Next rs.MoveNext%> </tr> <%Loop rs.close conn.close %> </table>
and it displays the image placeholder, but for the 'src' of the img it gives the right path, BUT then it adds a '#' and re-does the path
¦_____________Creator___Of___________¦ [-------------Newschoolskiing.com-------------]
Edited by - asp_newbie on 28 August 2001 13:44:56 |
|
|
Craig from Alberta
Starting Member
Canada
7 Posts |
Posted - 28 August 2001 : 17:45:13
|
Check your data in the database. The # is indicative of a bookmark. It must be coming from somewhere.
|
|
|
asp_storm
Average Member
USA
787 Posts |
|
sogoth
New Member
United Kingdom
73 Posts |
Posted - 29 August 2001 : 07:03:41
|
heya I'm doing something similar at the moment. All I'm doing is adding the image name to the database, uploading the image to a directory called covers and placing the following line whenever I want the image called by the recordset to appear...
<img src="covers/<%= (rsrev("cover"))%>" width="130" height="130">
it seems to work :) now all I need to do is work out how I can get the database to scan a directory and input all the names automatically... typing in the names of 3000 photos is going to be a complete git!
Paul - Complete Muppet, Borderline Feeble! |
|
|
asp_storm
Average Member
USA
787 Posts |
|
asp_storm
Average Member
USA
787 Posts |
|
Deleted
deleted
4116 Posts |
|
asp_storm
Average Member
USA
787 Posts |
|
big9erfan
Average Member
540 Posts |
Posted - 31 August 2001 : 03:42:21
|
I use this function to display ( in a textbox ) all jpg or gif files from a given directory
Function ListOrGetPict( bIsNew ) Dim objFSO Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Dim objFolder Dim strCurrentFolder
strCurrentFolder = "c:\directoy\images\"
Set objFolder = objFSO.GetFolder(strCurrentFolder) strGetPictListings = ""
'Now, use a for each...next to loop through the Files collection For Each objFile in objFolder.Files 'Check to see if objFile is pict file If Right(objFile.Name, 4) = ".gif" then 'Print out the violating file name and location strGetPictListings = strGetPictListings & "<option value='/PartOfURL/images/" & ObjFile.Name & "'>" & ObjFile.Name & "</option>" & vbCrLf End if
if Right(objFile.Name, 4) = ".jpg" then 'Print out the violating file name and location strGetPictListings = strGetPictListings & "<option value='/PartOfURL/images/" & ObjFile.Name & "'>" & ObjFile.Name & "</option>" & vbCrLf End if Next
Set objFSO = Nothing Set objFolder = Nothing
ListOrGetPict = strGetPictListings
end function %>
http://www.ugfl.net/forums |
|
|
|
Topic |
|