berndh
Posts: 10
|
Posted: 05/07/2004, 1:50 PM |
|
HI all,
running an Access database and need to do something like follows.
I need a script that checks if a certain file does exsist in a specific folder, if so it should show it, if not it should show another file.
ie check if "jumbo.jpg" exists in folder "/images/thumb", if not display "nf.jpg". the filename"jumbo.jpg" will be called from a database fiels called "img" and the "nf.jpg" will be a standard name for all failures.
Any clues for me ?
Thanks
|
|
|
peterr
Posts: 5971
|
Posted: 05/07/2004, 2:12 PM |
|
Hi,
I already replied to this question that you posted previously. Let me know if you have additional questions.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
berndh
Posts: 10
|
Posted: 05/07/2004, 2:49 PM |
|
Hi Peter,
that was unfortunately posted in the PHP group. is it the same to set up for ASP ?
Excuse my ignorance, just starting out, so I need a bit more help.
Thanks
|
|
|
peterr
Posts: 5971
|
Posted: 05/07/2004, 2:53 PM |
|
Yes, just use the same Google link and search for an ASP solution/function. Then replace your code "IsNull(adminbook.isbn.Value)" with the function you find.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
berndh
Posts: 10
|
Posted: 05/07/2004, 2:54 PM |
|
Thanks, will do.
|
|
|
berndh
Posts: 10
|
Posted: 05/07/2004, 3:11 PM |
|
Ok, me again.
Now I need some help here.
found the following that seems to be what I need, just need some help on how to implement it...
--------
Set fs=Server.CreateObject("Scripting.FileSystemObject")
If (fs.FileExists("c:\winnt\cursors\3dgarro.cur"))=true Then
Response.Write("File c:\winnt\cursors\3dgarro.cur exists.")
Else
Response.Write("File c:\winnt\cursors\3dgarro.cur does not exist.")
End If
set fs=nothing
---------------
The images are store in the db as "../images/books/ 000ES2048-A.jpg" and the db filed is called "picture"
How do I apply this into the example above and most importantly WHERE in CC do I type the expression into ?
Thanks
|
|
|
peterr
Posts: 5971
|
Posted: 05/07/2004, 3:26 PM |
|
There may be couple methods but you could try creating a label with custom code along these lines:
If fs.FileExists(FormName.LabelName.Value Then FormName.LabelName.Value = "<img src=" & FormName.LabelName.Value & ">" Else FormName.LabelName.Value = "<img src=nf.jpg>"
The code would go into the Before Show event of the Label.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
berndh
Posts: 10
|
Posted: 05/07/2004, 3:29 PM |
|
Thanks, will give it a bash in the morning.
Thanks
|
|
|
berndh
Posts: 10
|
Posted: 05/08/2004, 1:54 PM |
|
It is me again. Got some more help and came up with this code
Dim fso, filespec
filespec = buy.picture.Value
Set fso = CreateObject("Scripting.FileSystemObject")
If not (fso.FileExists(filespec)) Then
buy.picture.Value = "../images/books/blank.gif"
End If
Problem I have now is that the image name is stored in the db as "..image/books/name.jpg" and I think it is trying to see it that file exist (which it does not), thus I quite correctly get the blank.gif image showing up all the time now.
Any suggestions for me ?
|
|
|
peterr
Posts: 5971
|
Posted: 05/08/2004, 3:06 PM |
|
You could try modifying:
filespec = buy.picture.Value
by adding some path that reflects the image location, for example:
filespec = "C:/inetpub/wwwroot/WebsiteName" & buy.picture.Value
I'm not sure if this exactly will work, as for example you may need to replace "/" with "\", remove the ".." part, but not necessarily - it may work as is. I usually test the code and then adjust it as needed. You can find all necessary ASP functions at http://www.google.com/search?q=vbscript+functions
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
BlinkyBill
Posts: 86
|
Posted: 05/08/2004, 4:54 PM |
|
Quote peterr:
You could try modifying:
filespec = buy.picture.Value
by adding some path that reflects the image location, for example:
filespec = "C:/inetpub/wwwroot/WebsiteName" & buy.picture.Value
Ok to map virtual paths to physical paths you use server.mappath() eg:
Server.MapPath("dir1/file.some")
This returns: C:\site\scripts\dir1\file.some
Script also can call the MapPath with full virtual path:
Server.MapPath("/scripts/dir1/file.some")
more examples here:
http://www.google.com.au/search?hl=en&ie=UTF-8&oe=UTF-8...nG=Search&meta=
|
|
|
berndh
Posts: 10
|
Posted: 05/09/2004, 11:42 AM |
|
Hi guys....
Darn it works. Thanks a MILL... I'm so cahhed for all your help.
Final code as follows
Dim filespec, fso
filespec = (buy.picture.Value)
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(Server.MapPath( "../images/books/" & filespec) ) Then
buy.picture.Value = "../images/books/" & filespec
Else
buy.picture.Value = "../images/books/blank.gif"
End If
|
|
|