IF File type
2 posts by 2 authors in: Forums > CMS Builder
Last Post: July 22, 2008 (RSS)
By rjbathgate - July 21, 2008
Hi,
We have an upload field which allows jpgs, gifs and pdfs.
If the upload is a PDF it will be direct linked (i.e. so PDF is downloaded by end user) - i.e. <a href="name.pdf">Map</a>
If the upload is an image (jpg or gif), we want it to link to a page where the image is embended, i.e. <a href="image.php">Map</a>
Is there any php IF function which lets me define an IF statement based on the file extension/file type of the upload in the field?
I think it's a long shot...
Cheers in advance,
Rob
We have an upload field which allows jpgs, gifs and pdfs.
If the upload is a PDF it will be direct linked (i.e. so PDF is downloaded by end user) - i.e. <a href="name.pdf">Map</a>
If the upload is an image (jpg or gif), we want it to link to a page where the image is embended, i.e. <a href="image.php">Map</a>
Is there any php IF function which lets me define an IF statement based on the file extension/file type of the upload in the field?
I think it's a long shot...
Cheers in advance,
Rob
Re: [rjbathgate] IF File type
By Dave - July 22, 2008
Hi Rob,
Try something like this:
<?php if ($upload['extension'] == 'pdf'): ?>
... html code for pdf files ...
<?php else: ?>
... html code for other file types ...
<?php endif; ?>
Hope that helps!
Try something like this:
<?php if ($upload['extension'] == 'pdf'): ?>
... html code for pdf files ...
<?php else: ?>
... html code for other file types ...
<?php endif; ?>
Hope that helps!
Dave Edis - Senior Developer
interactivetools.com
interactivetools.com