Choose either JPG file or SWF file

Below the block of code gets the (a.jpg) image out of the models folder so it can be displayed. I would like to be able to have a (a.swf) file in the folder also and if the(.swf) is in the folder it will use that file instead of the (.jpg).

[php]$fn = $gn . “/a.jpg”;
if (file_exists($fn)) {
$ja = “|csaction name=“D61562B272” class=“Set Image URL” type=“onevent” val0=”";
$ja = $ja . $gn . “” val1="" . $gn . “/a.jpg”>";
$j1 = $j1 . “CSAct[/CMP/ ‘D61562B272’] = new Array(CSSetImageURL,/CMP/ '”;
$j1 = $j1 . $gn . “’,/URL/ '” . $fn . “’)\n\r”;

}[/php]

Well, right now you’re defining what image to select. If the flash file is the same way, you could just put both into an array. I don’t know how that would look physically, but the other alternative would be to put that into a function and call it with the image name.
[php]
$img = array(“a.jpg”, “a.swf”);
foreach($img as $fn) {
if (file_exists($gn."/"$fn)) {
$ja = “|csaction name=“D61562B272” class=“Set Image URL” type=“onevent” val0=”";
$ja = $ja . $gn . “” val1="" . $gn . “/a.jpg”>";
$j1 = $j1 . “CSAct[/CMP/ ‘D61562B272’] = new Array(CSSetImageURL,/CMP/ '”;
$j1 = $j1 . $gn . “’,/URL/ '” . $fn . “’)\n\r”;
}
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service