robjohnston
asked on
Images from asp pages
Hi folks.
Just a short one. I think we all have seen graphical hit counters from CGI pages. Can it be done with ASP?
Another expamle of this sort of thing would be ICQ's online graphic like the dll link below.
http://wwp.icq.com/scripts/online.dll?icq=120640177&img=7
Where a query gives a result and a suitable picture is displayed.
Cheers, Rob.
Just a short one. I think we all have seen graphical hit counters from CGI pages. Can it be done with ASP?
Another expamle of this sort of thing would be ICQ's online graphic like the dll link below.
http://wwp.icq.com/scripts/online.dll?icq=120640177&img=7
Where a query gives a result and a suitable picture is displayed.
Cheers, Rob.
if you have a hit count available, you can just parse the number of hits and then show a small image file of the number, move the the next digin and show its number image. Like 1234 you would show image for 1, image for 2, image for 3 and image for 4. It is the easiest way to do this with pure asp and no dynamic image creation.
that sucks, got beat by seconds..:o|
ASKER
Thank for the prompt replies, not quite what I'm looking for.
Something more like;
<IMG SRC="image.asp?x=y">
where the image shown would be generated by the page image.asp
Cheers, Rob.
Something more like;
<IMG SRC="image.asp?x=y">
where the image shown would be generated by the page image.asp
Cheers, Rob.
you can use something like the following:
<%
response.buffer=true
response.clear
response.contenttype="imag e/GIF"
response.binarywrite(<bina ry stream of data from sql or file system object>)
response.flush
%>
<%
response.buffer=true
response.clear
response.contenttype="imag
response.binarywrite(<bina
response.flush
%>
you can search msdn(or microsofts site) for "Delivering Web Images from SQL Server"
Are you looking for the code to identify a referer and his hits number (and increment that, and so on), or just to send some picture by an ASP (from a database or from a file)? - Please think of it, and be straight.
ASKER
John844 is on the right line.
This type of thing has got loads of app it could be used it, logging visitors to your sites and other many more.
Trying to get it to work reading a gif file like below, but it comes ups with a red cross, any ideas?
File: Image.asp
<%
response.buffer=true
response.clear
response.contenttype="imag e/GIF"
Const ForReading = 1 ' Input OutPut Mode
Const Create = False
' Declare local variables
Dim FSO ' FileSystemObject
Dim TS ' TextStreamObject
Dim strLine ' local variable to store Line
Dim strFileName ' local variable to store fileName
strFileName = Server.MapPath("1.gif")
' Instantiate the FileSystemObject
Set FSO = Server.CreateObject("Scrip ting.FileS ystemObjec t")
Set TS = FSO.OpenTextFile(strFileNa me, ForReading, Create)
ImgLine = TS.Readall ' Read the file
response.binarywrite ImgLine
response.flush
' close TextStreamObject and destroy local variables to relase memory
TS.Close
Set TS = Nothing
Set FSO = Nothing
%>
Cheers, Rob.
This type of thing has got loads of app it could be used it, logging visitors to your sites and other many more.
Trying to get it to work reading a gif file like below, but it comes ups with a red cross, any ideas?
File: Image.asp
<%
response.buffer=true
response.clear
response.contenttype="imag
Const ForReading = 1 ' Input OutPut Mode
Const Create = False
' Declare local variables
Dim FSO ' FileSystemObject
Dim TS ' TextStreamObject
Dim strLine ' local variable to store Line
Dim strFileName ' local variable to store fileName
strFileName = Server.MapPath("1.gif")
' Instantiate the FileSystemObject
Set FSO = Server.CreateObject("Scrip
Set TS = FSO.OpenTextFile(strFileNa
ImgLine = TS.Readall ' Read the file
response.binarywrite ImgLine
response.flush
' close TextStreamObject and destroy local variables to relase memory
TS.Close
Set TS = Nothing
Set FSO = Nothing
%>
Cheers, Rob.
here is a link to something. have not tried the code yet.
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6142
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6142
Have heard that aspUpload does the same thing as well.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi folks.
Well John844, you're solution works, but when I approached my hosting co about installing dll's they said "no way".
There is another solution though, outlined here:
http://www.4guysfromrolla.com/webtech/052400-1.shtml
Basically the method is to do the work in the asp page then use response.redirect to the required image. Easy as that!
Anyway points to John844 as his solution is valid. Thanks everyone for your help, Rob.
Well John844, you're solution works, but when I approached my hosting co about installing dll's they said "no way".
There is another solution though, outlined here:
http://www.4guysfromrolla.com/webtech/052400-1.shtml
Basically the method is to do the work in the asp page then use response.redirect to the required image. Easy as that!
Anyway points to John844 as his solution is valid. Thanks everyone for your help, Rob.
assume we store the recordcount into a variable called 'recordcount'
<%
' set recordcount equal to something
recordcount = 15556987
' get length of the count
recordlength = len(Recordcount)
' set position of count equal to starting point
position = 1
' go through each number in the count
for inti = 0 to recordlength
"<IMG SRC=" & mid(recordcount, position, 1) & ".jpg>"
' up the default position by one.
position = position + 1
next
%>
that should do it for ya.