# Checking if a File Exists

**URL:** <https://forum.kirupa.com/t/checking-if-a-file-exists/262417>\
**Category:** Uncategorized\
**Created:** [June 5, 2008, 6:58pm UTC](https://forum.kirupa.com/t/checking-if-a-file-exists/262417 "2008-06-05T18:58:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbeanz](https://avatars.discourse-cdn.com/v4/letter/t/53a042/32.png) [@tbeanz](https://forum.kirupa.com/u/tbeanz)\
**Post date:** [June 5, 2008, 6:58pm UTC](https://forum.kirupa.com/t/checking-if-a-file-exists/262417/1 "2008-06-05T18:58:39Z")

</div>

Hey all,

I was wondering if there is a simple way to check if a file of a certain type (specifically, FLV) exists within a folder, using AS3. What I want to do is something along these lines…

```auto

if(an FLV file exists within a certain folder){
      //Do something!
}

```

Any help would be much appreciated. Thanks in advance!

tbeanz

---

<div class="post-metadata">

**Author:** ![Anogar](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anogar](https://forum.kirupa.com/u/Anogar)\
**Post date:** [June 5, 2008, 9:58pm UTC](https://forum.kirupa.com/t/checking-if-a-file-exists/262417/2 "2008-06-05T21:58:13Z")

</div>

Sorry, this isn’t possible without help from a server-side script running on your web server. (PHP / ASP / etc…)

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [June 6, 2008, 12:34am UTC](https://forum.kirupa.com/t/checking-if-a-file-exists/262417/3 "2008-06-06T00:34:39Z")

</div>

Not sure about AS3 but this AS2 code works - just try loading the file (even if Flash can’t actually use it) and check the onLoad handler:

```auto
fileExists = new LoadVars();
fileExists.onLoad = function(success) {
	//success is true if the file exists, false if it doesnt
	if (success) {
		//the file exists
		trace("the file " + fileName + " exists");
	} else {
		trace("the file " + fileName + " doesn't exist");
	}
};
fileName = "http://www.mysite.com/video.flv";
fileExists.load(fileName);

```

---

<div class="post-metadata">

**Author:** ![Anogar](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@Anogar](https://forum.kirupa.com/u/Anogar)\
**Post date:** [June 6, 2008, 12:47am UTC](https://forum.kirupa.com/t/checking-if-a-file-exists/262417/4 "2008-06-06T00:47:07Z")

</div>

That’d work if he wanted to check for a specific file name, but I think he wanted to look for any and all FLV files, which is a little harder.

---

<div class="post-metadata">

**Author:** ![tbeanz](https://avatars.discourse-cdn.com/v4/letter/t/53a042/32.png) [@tbeanz](https://forum.kirupa.com/u/tbeanz)\
**Post date:** [June 6, 2008, 1:07pm UTC](https://forum.kirupa.com/t/checking-if-a-file-exists/262417/5 "2008-06-06T13:07:22Z")

</div>

Thanks for your help, guys. I’ll definitely look into the server-side script. I remember you can do file checking easily with PHP, so I’ll give that a try.
