Irish SEO,  Marketing & Webmaster Discussion

 

php - read filename extension in database

This is a discussion on php - read filename extension in database within the Coding Help forums, part of the Webmaster Help category; Hi, I wonder if anyone can help me with this. I have a recordset to get the names of files ...


Go Back   Irish SEO, Marketing & Webmaster Discussion > Webmaster Help > Coding Help

Register Forum Rules FAQDonate Calendar Search Today's Posts Mark Forums Read

  #1 (permalink)  
Old 16-10-2008, 01:11 PM
Dotwebs's Avatar
Coder
 
Join Date: Jul 2008
Location: Dublin (Sort of)
Posts: 97
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Dotwebs will become famous soon enough
Send a message via Skype™ to Dotwebs
Default php - read filename extension in database

Hi,

I wonder if anyone can help me with this. I have a recordset to get the names of files to download, these are mostly PDFs so I have added the code to output a PDF file. If the file is not pdf I want to output it in the correct format.

So
PHP Code:
if (file is pdf) {
// We'll be outputting a PDF 
header('Content-type: application/pdf'); 
// called download.pdf 
header('Content-Disposition: inline; filename="download.pdf"'); 
// The source of the PDF
readfile("../pathtofile/".$row_rsFilelist['filename']); 
 
} else {
//we'll output probably just a link

any help would be appreciated.

Thanks
__________________
The cure for boredom is curiosity. There is no cure for curiosity - Dorothy Parker
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 16-10-2008, 03:02 PM
louie's Avatar
Senior Member
 
Join Date: Jan 2006
Location: Dublin, Ireland
Posts: 2,204
Nominated 6 Times in 4 Posts
Nominated TOTW/F/M Award(s): 1
louie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud oflouie has much to be proud of
Send a message via Yahoo to louie Send a message via Skype™ to louie
Default

You can use filetype function available in php

PHP: filetype - Manual

or you can check for the ".pdf" using stristr

PHP: stristr - Manual
__________________
:. Web Design & Development Web Design Ireland
:. Search Engines Optimization Search Engines Optimization
:. Car Parts & Accessories Car Parts
:. Cars Ireland Cars Ireland
:. I Have 2 Find It Directory SEF Directory
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 16-10-2008, 06:31 PM
Dotwebs's Avatar
Coder
 
Join Date: Jul 2008
Location: Dublin (Sort of)
Posts: 97
Nominated 0 Times in 0 Posts
TOTW/F/M Award(s): 0
Dotwebs will become famous soon enough
Send a message via Skype™ to Dotwebs
Default

Thanks Louie, I found a solution that works - here it is in case anyone else needs it:

if(strtolower(substr($row_rsFilelist['filename'], strlen($row_rsFilelist['filename'])-3)) == 'pdf'))

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
database, download, extension, filename, pdf, php, read

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Read before posting domains for sale blacknight Domains For Sale 2 11-04-2008 02:53 PM
Do you read AUP / TOS before signing up? blacknight Hosting 14 05-02-2008 03:21 PM
Harry Potter - Will you read it? blacknight Off topic discussion 1 19-07-2007 03:39 PM


Sponsored links

Pepperjam Network
Paid On Results www.zanox.com


All times are GMT +1. The time now is 04:19 PM.


Powered by: vBulletin Version 3.8.2, Copyright ©2000 - 2009, Jelsoft Enterprises Limited.
Hosted in Ireland by Blacknight - Test your ISP |Irish Hosting Directory| Armchair.ie|Logo by Eden Web Design|Avatars by Afterglow |Latest Blog Entries | VPS HostingAd Management by RedTyger

Search Engine Friendly URLs by vBSEO 3.3.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51