Jump to content

Checking a PDF file exists on a server without downloading

Recommended Posts

Hi guys

I want to check if a PDF file exists on a server . I use httprequest to do this at the moment but if it finds the file it downloads which uses a lot of bandwidth. I just want to return a true / false on if it exists or not. Below is my code , can anyone suggest a code edit to do what I need. Thanks for any help in advance.


$cat = 8878000
$sTestUrl = "https://www.blah.com/files/" & StringRight(Hex($cat),6) & ".pdf"

With $oHttpRequest
   .SetTimeouts ($ResolveTimeout, $ConnectTimeout, $SendTimeout, $ReceiveTimeout)
   .Open ("GET", $sTestUrl)
      Case .Status = 200;No problem!
        Local $file = FileOpen("test2.txt", 1)
    fileWrite($file, "https://www.blah.com/files/" & StringRight(Hex($cat),6) & ".pdf" & @CRLF)
    $tempFile = "d:\temp\" & StringRight(Hex($cat),6) & ".pdf"

      $temp = fileopen($tempFile,2)
      Case .Status = 404;Not found
        ConsoleWrite($sTestUrl & " could not be found (404 Error)" & @CR)
      Case Else;Some other problem
        ConsoleWrite("An unexpected HTTP Status value was returned: " & .Status & @CR)


Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...