# JPEG File verification using loadVar

**URL:** <https://forum.kirupa.com/t/jpeg-file-verification-using-loadvar/127903>\
**Category:** flash\
**Created:** [November 7, 2004, 9:43pm UTC](https://forum.kirupa.com/t/jpeg-file-verification-using-loadvar/127903 "2004-11-07T21:43:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hillcreative](https://avatars.discourse-cdn.com/v4/letter/h/e47774/32.png) [@hillcreative](https://forum.kirupa.com/u/hillcreative)\
**Post date:** [November 7, 2004, 9:43pm UTC](https://forum.kirupa.com/t/jpeg-file-verification-using-loadvar/127903/1 "2004-11-07T21:43:53Z")

</div>

I’m building an array of JPEG files from an XML file. I need a way to verify that the file exists on the server as it build the array. If it’s not there I want to substitute another file name in it’s place: default.jpg.

Using loadVars I came up with this code… which won’t work:

//Loop parse XML for recently played songs and verify file on server  
var img\_array = new Array();//JPEG file names  
var desc\_array = new Array();//Text descriptions of JPEG files  
for (var i=13; i \< 23; i++) {//Checks only between nodes specified  
var t\_name = doc.firstChild.childNodes\*.attributes.name;//Get image file name from XML  
//Check to see if JPEG file exists on server  
fileExists = new LoadVars();  
fileExists.load(pRadio + “/thumbs/” + t\_name);//URL path to actual file  
fileExists.onLoad = function (success) {  
if (success) {  
img\_array.push(t\_name);//On success adds file name to img\_array _ **Verified** _  
} else {  
t\_name=“default.jpg”;//On failure substitute default.jpg file name and push to array  
img\_array.push(t\_name);  
}  
}  
//Parse description text and push to array  
var t\_desc = doc.firstChild.childNodes\*.firstChild.nodeValue;  
if (t\_desc== undefined) t\_desc = “”;  
desc\_array.push(t\_desc);  
}

I posted this on the FLASH forum but the only answer I got was that it can’t be done and I should use a server-side script. Flash should be able to tell if a load failed or not…yes. Any suggestions would be greatly appreciated.

hillcreative
