Skip to main content
Inspiring
May 4, 2008
Question

Powerpoint uploads and MIME types

  • May 4, 2008
  • 11 replies
  • 640 views
I am building an application to upload PPT files. I want to test the
incoming filenames to see if it *is* a PPT file, but cannot find a MIME type
for it. How should I do this so that I only allow such files to be
uploaded?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


This topic has been closed for replies.

11 replies

Inspiring
May 4, 2008
On 03 May 2008 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:

> I am building an application to upload PPT files. I want to test
> the incoming filenames to see if it *is* a PPT file, but cannot find
> a MIME type for it. How should I do this so that I only allow such
> files to be uploaded?

application/vnd.ms-powerpoint ppt

http://www.w3schools.com/media/media_mimeref.asp

I just checked several Powerpoint files - the first 8 bytes are (hex)
d0 cf 11 e0 a1 b1 1a e1
in all the files I checked. So you can:
- upload the file
- open the file up and examine the first 8 bytes:
$handle = fopen($filename, "rb");
$contents = fread($handle, 8);
if ($contents != $testvalue) { ...
- for dealing with the binary string, see bin2hex and pack

http://www.php.net/manual/fopen
http://www.php.net/manual/fread
http://www.php.net/bin2hex
http://www.php.net/pack

(This is PHP, right?)

I'd also examine a few more powerpoint files - I think that there are a
few different types? - to be sure that the signature I list is
characteristic. And remember that Microsoft completely changed file
structures for Office 2007, and that .pptx is probably completely
different to all other previous formats...

http://en.wikipedia.org/wiki/Microsoft_PowerPoint#File_formats

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/contact.php