creating a link that looks for a file

K

Kelly****

How would you creat a link that looks for a file if it
doesnt find it it doesnt do anything if it does it opens
the file
 
S

Steve Easton

Looks for a file where??

--
Steve Easton
Microsoft MVP FrontPage
95isalive
This site is best viewed............
........................with a computer
 
J

Jens Peter Karlsen[FP MVP]

Not possible. If it isn't there you will get a 404 fault page.
Simple solution. Don't create links to pages that are not there.

Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
 
K

Kelly****

The files will be place in a news folder. The idea is to
be able to create links on a calender for each day of the
month for excample jan 1 the link would be jan1.pdf, Jan 2
would be jan2.pdf and so on.
My thoughts are so the person taking care of the news and
events for what ever date it may be would just upload the
file to the news folder all he would have to remember it
to name it jan1.pdf or jan2.pdf and so on.
 
J

Jon Spivey

Hi Kelly,

You'll need a little programming to do this - check what's available on your
server. I'll give an ASP (Windows Server) solution because that's fairly
common. First we'll loop through the days of January then for each day
check if a file named /news/Jan1.pdf, /news/jan2.pdf etc is available. If
it exists write a link to it - if it doesn't do nothing and go to the next
day
<%
set f = createobject("scripting.filesystemobject")
for i = 1 to 31
if f.fileexists(server.mappath("/news/jan" & i & ".pdf")) then
response.write "<a href=""/news/jan" & i & ".pdf"">Jan " & i & "</a><br>"
end if
next
%>

Hopefully this will give you a start.
 
K

Kelly******

Im new to all this sorry
But where do I place this code and is the mappath on the
server something like http:\mywebsite\httpdos\news
for excample
 
S

Stefan B Rusynko

That code will only work in a .asp page and If you are hosted on a Windows Server supporting ASP
Check w/ your host if you don't know
The code goes in your html code where you want the link (repeated for each day)
- you would use it for each link to your pdfs in a folder named news
- you don't need to change the code since it resolves server side to the files
news/janX.pdf where the "i" in the code is for each day of the month

You would need change the "jan" (twice) to "feb" and "mar", etc for each month
That would be 365 links done that way for an entire year!

IMHO a cumbersome solution
- see my other post



| Im new to all this sorry
| But where do I place this code and is the mappath on the
| server something like http:\mywebsite\httpdos\news
| for excample
| >-----Original Message-----
| >Hi Kelly,
| >
| >You'll need a little programming to do this - check
| what's available on your
| >server. I'll give an ASP (Windows Server) solution
| because that's fairly
| >common. First we'll loop through the days of January
| then for each day
| >check if a file named /news/Jan1.pdf, /news/jan2.pdf etc
| is available. If
| >it exists write a link to it - if it doesn't do nothing
| and go to the next
| >day
| ><%
| >set f = createobject("scripting.filesystemobject")
| >for i = 1 to 31
| >if f.fileexists(server.mappath("/news/jan" & i & ".pdf"))
| then
| >response.write "<a href=""/news/jan" & i & ".pdf"">Jan "
| & i & "</a><br>"
| >end if
| >next
| >%>
| >
| >Hopefully this will give you a start.
| >
| >--
| >Cheers,
| >Jon
| >Microsoft MVP
| >
| >
| in message
| >| >> The files will be place in a news folder. The idea is to
| >> be able to create links on a calender for each day of
| the
| >> month for excample jan 1 the link would be jan1.pdf,
| Jan 2
| >> would be jan2.pdf and so on.
| >> My thoughts are so the person taking care of the news
| and
| >> events for what ever date it may be would just upload
| the
| >> file to the news folder all he would have to remember it
| >> to name it jan1.pdf or jan2.pdf and so on.
| >>
| >>>-----Original Message-----
| >>>How would you creat a link that looks for a file if it
| >>>doesnt find it it doesnt do anything if it does it opens
| >>>the file
| >>>.
| >>>
| >
| >
| >.
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top