473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

check if PDF file is valid?

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
2 3811
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Chris | last post by:
Hi, In C# I tried to save a file from a generated file name. Just before launching the dialog I check for a valid file name to be sure. There for I used the method ValidateNames from the save...
2
by: Adrian | last post by:
Hi I have a text box where I can paste XML docs into and then send them however sometimes the call fails I assume to incorrectly formatted text! it fails on the line below: ...
3
by: puja | last post by:
hi all, In asp.net 2.0 there is a limit on file size upload of 4MB. I know this limit can be increased in web.config file. Is there any way to check the file size before upload ? if user is...
3
by: satees | last post by:
Hi, I need to check the given email address is valid or not within the specified server. For eg: If i give the address xyz@yahoo.com, the code need to check with the yahoo server whether the id...
0
by: Bhavan Thejpal | last post by:
hi, in a web application we are building, we have a 'upload file' functionality.I need to check whether the user is uploading a valid word file.( it should be a valid, uncorrputed Word file). ...
1
by: jtertin | last post by:
I am currently using the following code to make sure a file is writable (i.e. is not in use) by using the CanWrite method of the FileStream object. Using the code below, the TextWriter is still...
4
by: Anthony2oo5 | last post by:
Hey there, I'm trying to write a script for uploading images but only with certain file extensions. Currently I have it working by: if (($FileExt = "jpg") || ($FileExt = "gif")) ect, but is...
2
by: lucky13 | last post by:
Hello All, I want to check the Valid E-mail id is entered by user or not in the e-mail id field. means if user will not enter the @ sign & Domain name , user must receive a message that" Please...
2
Manikgisl
by: Manikgisl | last post by:
HI. How to check File exists in Web Share C# try { WebRequest request = HttpWebRequest.Create("http://www.microsoft.com/NonExistantFile.aspx"); request.Method = "HEAD"; // Just get...
3
Frinavale
by: Frinavale | last post by:
Hi there! I'm hoping that someone knows how to check the size of a file before it is uploaded to the server using JavaScript. I have seen suggested solutions using an ActiveX control to check...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.