By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,830 Members | 2,276 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,830 IT Pros & Developers. It's quick & easy.

check if PDF file is valid?

P: n/a
Hi,

I'm using PHP 4.4.4 but can upgrade if necessary. Given a path to a
file on my server, is there a way I can check if that file is of a PDF
format? I'm guessing the answer to this may depend on some versioning
info too, so if that's true, let's just consider for the latest verion
of PDF.

Thanks for your help, - Dave
Feb 14 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
la***********@zipmail.com wrote:
I'm using PHP 4.4.4 but can upgrade if necessary. Given a path to a
file on my server, is there a way I can check if that file is of a PDF
format? I'm guessing the answer to this may depend on some versioning
info too, so if that's true, let's just consider for the latest verion
of PDF.
If you're running your scripts on a linux (or unix) server, just run
the "file" command to know the type of file.

e.g.:

$type = shell_exec("file $filename");

--
----------------------------------
IvŠn SŠnchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Ruido en la l√*nea cortes√*a de Telef√≥nica.
Feb 14 '08 #2

P: n/a
On 14 Feb, 22:11, IvŠn SŠnchez Ortega <ivansanchez-...@rroba-
escomposlinux.-.punto.-.orgwrote:
laredotorn...@zipmail.com wrote:
I'm using PHP 4.4.4 but can upgrade if necessary. Given a path to a
file on my server, is there a way I can check if that file is of a PDF
format? I'm guessing the answer to this may depend on some versioning
info too, so if that's true, let's just consider for the latest verion
of PDF.

If you're running your scripts on a linux (or unix) server, just run
the "file" command to know the type of file.

e.g.:

$type = shell_exec("file $filename");
For a given value of 'valid'. A more rigourous solution might be to
run it through pdftops then back through pstopdf

C.
Feb 15 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.