# How to check whether file exists on server

**URL:** <https://forum.kirupa.com/t/how-to-check-whether-file-exists-on-server/59670>\
**Category:** flash\
**Created:** [August 2, 2004, 9:58pm UTC](https://forum.kirupa.com/t/how-to-check-whether-file-exists-on-server/59670 "2004-08-02T21:58:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ordinathorreur](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ordinathorreur/32/536_2.png) [@Ordinathorreur](https://forum.kirupa.com/u/Ordinathorreur)\
**Post date:** [August 2, 2004, 9:58pm UTC](https://forum.kirupa.com/t/how-to-check-whether-file-exists-on-server/59670/1 "2004-08-02T21:58:57Z")

</div>

I am building a dynamic photo gallery and have run into a problem.

I am using next and previous buttons. This code, for instance, is for the next button.

```auto
 
on(release){
 _global.picnumber = picnumber +1;
 _root.container.loadMovie(picnumber+".jpg");
}

```

Obviously I can only have a set amount of pictures so I need to check whether or not the file exists on my server. If it does not exist, it has to load “1.jpg”  
The reason I want to check is that I would like to just upload pictures in a sequential order and not touch my fla.

Can someone help me out with a nice if statement that checks whether or not a file exists?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 3, 2004, 6:01am UTC](https://forum.kirupa.com/t/how-to-check-whether-file-exists-on-server/59670/2 "2004-08-03T06:01:52Z")

</div>

yes, someone can, and his name is PHP…  
Flash alone can’t do that, PHP can read all the files in a directory, and if you want, send the list to the swf. See server-side forum for details.  
If you don’t want to use a scripting language, then you’ll need to use a text, or better xml config file which you update manually and flash reads in to set up the image viewer.  
can be as simple as  
\< files total=10 / \>

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 3, 2004, 9:02am UTC](https://forum.kirupa.com/t/how-to-check-whether-file-exists-on-server/59670/3 "2004-08-03T09:02:17Z")

</div>

PHP also has a file\_exists function, that immediately checks if a file exists or not. A lot shorter than getting a list and running through it to see if it’s in there.  
There is also a way to check it from Flash, using the LoadVars object. FlashGuru has an article on it I think … yup: [http://www.flashguru.co.uk/000310.php](http://www.flashguru.co.uk/000310.php)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 3, 2004, 4:30pm UTC](https://forum.kirupa.com/t/how-to-check-whether-file-exists-on-server/59670/4 "2004-08-03T16:30:57Z")

</div>

I was thinking it might be PHP or some server side tomfoolery, thanks for the replies. Its time to do some research…
