This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes PHP and the fly likes Uploading a file other than an image. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Languages » PHP
Bookmark "Uploading a file other than an image." Watch "Uploading a file other than an image." New topic

Uploading a file other than an image.

Shamsudeen Akanbi
Ranch Hand

Joined: Dec 24, 2010
Posts: 76
Hi fellas, I'm writing an application that will allow a user to upload a .pdf, .doc or .xls file. I still get an error whenever I upload that: The screen shot must be a GIF, JPEG, or PNG image file no greater than 3200000 KB in size. Isn't it possible to upload a pdf/doc(x) file in php and store it in a database of MySql. This program works well if i upload image file within the specified size. Learning sometimes can be frustrating!

The addscore script that should allow .pdf and co:

The appvars.php code:

This is the index page:

Thank you in anticipation.

Nick Charles
Ranch Hand

Joined: Oct 09, 2011
Posts: 71

You are using the wrong mime types. For example, a .docx file uses the mime type application/vnd.openxmlformats-officedocument.wordprocessingml.document. Here is a list of the various Microsoft Office document mime types:

I'll let you Google for the other mime types.

By the way, why not add the mime type to the error message on lines 91-92, that is a good way to find out mime types of file types that you can't handle.
Shamsudeen Akanbi
Ranch Hand

Joined: Dec 24, 2010
Posts: 76
Thank You bro, it worked like a charm! The only problem i'm facing now is that now that i can upload pdf and doc files, i can't upload pictures anymore. It has to do with something in my script so i'm trying to sort it myself. Thank you once again.
I agree. Here's the link:
subject: Uploading a file other than an image.
It's not a secret anymore!