USING IF STATEMENTS TO DEFINE OUTPUT BASED ON A FILE EXTENSION - Aug 16th, 2011


If you need to publish specific code that’s based on the type of file that you’ve uploaded into an upload field,
like a .swf flash file, here’s the trick. Just use:



<?php if ($upload['extension'] == 'swf'): ?>



or for the second through next to last if parameter in the list (the last one gets an <?php else: ?> instead of a <?php
elseif...)



<?php elseif ($upload['extension'] == 'swf'): ?>



You can use this for non upload fields as well:



<?php if ($your_fieldRecord['extension'] == 'doc'): ?>




or



<?php elseif ($your_fieldRecord['extension'] == 'doc'): ?>




Don’t forget that every if statement must be closed with an <?php endif ?>



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service