Welcome Guest, Not a member yet? Register   Sign In
How to determine file type before opening ?
#1

[eluser]quest13[/eluser]
Hi, I upload a image or pdf and store the path in a database and save the file under the folder uploads.When I provide 'View' to a user,I want to give a link only if the file stored is a pdf else if it is a image, I just want to directly display without any link.In order to do this, I want to confirm the file type.Can anyone tell me how it is done?

ex: image-- > uploads/test1.jpg

pdf-- >uploads/test1.pdf


Thanks in advance
#2

[eluser]Dam1an[/eluser]
One of the pieces of data you get when you upload a file is if it's an image (is_image) and it's width and height if it is
Just store the boolean (and optionally dimensions) in the database, then it's just a simple boolean check in the view if it's an image or pdf




Theme © iAndrew 2016 - Forum software by © MyBB