Jump to content
Server Maintenance This Week. ×

Check if file (image) exists on web server


This topic is 6476 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

Hi, I'm hoping someone can help.

I'm building an image library and I need to be able to check (ie set a field to true or false) if an image exists on a remote server over the internet.

eg :P http://www.site.com/folder/subfolder/image.gif

The best solution I've come up with so far is call a shell script that will download the image locally, check if it exists in a specific local location and return yes or no, then delete the local copy.

Is there potentially a one step, cleaner solution?

This is eventually going to be part of a loop trawling through thousands of images, so the cleaner/faster, the better.

I'm using 8.5 Pro on OS X 10.4.7.

Link to comment
Share on other sites

There may be a better way, but I see that curl has an -I option (that's a capital i), which returns only the header of the file. It does not download the file.

If file is there, 1st line: "HTTP/1.1 200 OK"

Otherwise 1st line: "HTTP/1.1 404 Not Found"

Link to comment
Share on other sites

  • Newbies

That's great, I'll experiment with that.

This is the first project I've undertaken with 8.5 and I see there's a web viewer field that may also do exactly what I need if I populate it with the image URL.

Thanks.

Link to comment
Share on other sites

This topic is 6476 days old. Please don't post here. Open a new topic instead.

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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.