Closed Thread Icon

Preserved Topic: JS to detect if a file exists? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=17940" title="Pages that link to Preserved Topic: JS to detect if a file exists? (Page 1 of 1)" rel="nofollow" >Preserved Topic: JS to detect if a file exists? <span class="small">(Page 1 of 1)</span>\

 
Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 04-30-2001 17:23

Greets!

I have some press releases in HTML that will also be available in PDF. Can JavaScript determine if a file exists? I'd like to have a "Download this press release in .PDF" type icon on the HTML versions, but only if the .pdf file exists. Can this be done?

Pat Richard
A pixel is worth a thousand words.
http://www.gurusnetwork.com
ICQ 23113317

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 04-30-2001 17:40

I don't believe so... that would be a server side function, you will have to delve into some simple perl or php to get this one done.

see server-side forum.

-mage-

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 05-02-2001 07:34

Pugzly, I wrote a simpe CGI script that can check if PDF file is available and display link to it. You can download it from here: http://www.max.co.yu/ozone/pdf.pl.txt Before using it, you must configure two variables at the top of the script ($mainFolder and $mainURL). After that, you can call the script using SSI, like this: <!--#include virtual="/cgi-bin/pdf.pl?filename=bla.pdf" #-->

DocOzone
Maniac (V) Lord Mad Scientist
Sovereign of all the lands Ozone and just beyond that little green line over there...

From: Stockholm, Sweden
Insane since: Mar 1994

posted posted 05-03-2001 02:25

That was a keeper, most definitely. Thanks mr.maX, you're my hero, honest and truly!

Your pal, -doc-

Pugzly
Paranoid (IV) Inmate

From: 127.0.0.1
Insane since: Apr 2000

posted posted 05-16-2001 17:59

Okay. I have one question....

What's best way to yank out a "/"?

What I want to do was just put the root DIR in the script, and then define the full path in the SSI call. The script does correctly determine whether the file exists, but the link created to it has an extra "/" in it.

I have been using something like /development/news.htm in the SSI call. I know I could pull the slash out in the SSI call, but I want to be able to look for .pdf files in different folders, so I need to specify a path. Since the calls could be coming from various files in various folders, I need the leading slash.

What I did was open the script, remove the "\" between $mainURL and $fileName, like this:

print "<A HREF=\"$mainURL\$fileName\">Download this press release in .PDF</A><br>\n\n";


to

print "<A HREF=\"$mainURL$fileName\">Download this press release in .PDF</A><br>\n\n";



That seems to work fine, but I just want to make sure that's not a problem with putting the two variable together like that.

Just trying to hack my way through life....


Pat Richard
A pixel is worth a thousand words.
http://www.gurusnetwork.com
ICQ 23113317

linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 05-16-2001 18:08

Is that Perl?

If so, should work fine. That's a legal doublequoted string.

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 05-16-2001 19:19

Pugzly, that's fine...

« BackwardsOnwards »

Show Forum Drop Down Menu