phil2564 Posted December 9, 2012 Share Posted December 9, 2012 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). $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"; } Quote Link to comment https://forums.phpfreaks.com/topic/271786-choosing-either-jpg-file-or-swf-file/ Share on other sites More sharing options...
MDCode Posted December 9, 2012 Share Posted December 9, 2012 It's really not that complicated...change all the .jpg to .swf Quote Link to comment https://forums.phpfreaks.com/topic/271786-choosing-either-jpg-file-or-swf-file/#findComment-1398386 Share on other sites More sharing options...
Andy123 Posted December 9, 2012 Share Posted December 9, 2012 (edited) You could do like this: $swf = 'some.swf'; $image = 'some.jpg'; if (file_exists($swf)) { // Show swf } else if (file_exists($image)) { // Show image } else { // Nothing to show } Edited December 9, 2012 by Andy123 Quote Link to comment https://forums.phpfreaks.com/topic/271786-choosing-either-jpg-file-or-swf-file/#findComment-1398387 Share on other sites More sharing options...
phil2564 Posted December 9, 2012 Author Share Posted December 9, 2012 (edited) Is there away to have this $fn = $gn . "/a.jpg"; Be either JPG or SWF depending what I put in that particular folder it will display. SO if there is a a.jpg t will display that or if there is a a.swf it will display that. Edited December 9, 2012 by phil2564 Quote Link to comment https://forums.phpfreaks.com/topic/271786-choosing-either-jpg-file-or-swf-file/#findComment-1398421 Share on other sites More sharing options...
MDCode Posted December 9, 2012 Share Posted December 9, 2012 You could do like this: $swf = 'some.swf'; $image = 'some.jpg'; if (file_exists($swf)) { // Show swf } else if (file_exists($image)) { // Show image } else { // Nothing to show } To break down what andy posted this basically states: if the .swf file exists, then you write your code to show it. If it does not exist but the image does, then you write your code to show that. If neither exists do whatever. Either way you will have to check which exists first before doing anything Quote Link to comment https://forums.phpfreaks.com/topic/271786-choosing-either-jpg-file-or-swf-file/#findComment-1398425 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.