how to check image exist in javascript

They have: 2 posts

Joined: Aug 2004

I've been on the hunt for a simple little function that will detect whether or not an image file exists when a user selects the file from their hard drive or types in the location. Just need it to alert that there is no such file if it truly does not exist. IE only.

KarenArt's picture

She has: 354 posts

Joined: May 2001

Is this for file uploading or something else?
I'm confused as to what you want to check. Confused

They have: 2 posts

Joined: Aug 2004

Is this for file uploading or something else? ---uploading image

I'm confused as to what you want to check.

i want to check if the image really exist , when a user selects the file from their hard drive or types in the location. Just need it to alert that there is no such file if it really doesnot exits

I have got a sample code

<script language="JavaScript">

</script>

KarenArt's picture

She has: 354 posts

Joined: May 2001

Sorry! I didn't want you to think I was ignoring you... I just don't know the answer to your question. Sad

The only javascript code I know for uploading and checking a file checks the extension of the file and makes sure it uploads alright, but I don't know how to check to make sure it exists before it's uploaded.

Hopefully someone smarter than me (which includes a lot of people) will be able to help you.

*Edit to add: It looks like you may not be calling up the function for your alerts. Have you tried using...

tester.onload=isGGood();
tester.onerror=isBBad();
'
I also don't see the function for new Image(). Is it somewhere else?

gotta finish redesigning my sites so I can show them again.

The purpose of education is... to get more jokes!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.