473,466 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Image Mime Type Problem

chunk1978
224 New Member
hi. i have this mime-type array in my php upload script... but my mime type for photoshop files isn't working. what's wrong with this?

Expand|Select|Wrap|Line Numbers
  1. # -=-=-=- Allowed File Extensions:  .TIF / .PSD / .JPG / .JPEG / .JPE / .PNG
  2.  
  3. $mimetypes = array
  4. (
  5. 'image/tiff',
  6. 'image/vnd.adobe.photoshop',
  7. 'image/jpeg',
  8. 'image/png',
  9. );
  10.  
May 5 '07 #1
1 1464
pbmods
5,821 Recognized Expert Expert
Try

Expand|Select|Wrap|Line Numbers
  1. print($_FILES['whateverYouCalledIt']['type'];
  2. exit;
  3.  
To see why it's not matching.

[EDIT: Incidentally, if you made the array keys the accepted types, your script would execute a tiny bit faster as it could use a reference instead of have to loop through the entire array to find a matching MIME type.

E.g.:

Expand|Select|Wrap|Line Numbers
  1. $mimetypes = array
  2. (
  3. 'image/tiff', => true,
  4. 'image/vnd.adobe.photoshop', => true,
  5. 'image/jpeg', => true,
  6. 'image/png', => true
  7. );
  8.  
  9. if(! $mimetypes[$_FILES['whateverYouCalledIt']['type']]) {
  10.     header('Location:  somepage.php?message=MIME_TYPE_MISMATCH');
  11.     exit;
  12. }
  13.  
The other advantage of doing this is that if you wanted to temporarily disable support for a particular mime-type, you could just set its value to false instead of deleting it or commenting it out).
]
May 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Phil Powell | last post by:
How do you detect an image MIME type if you know of the image in a directory? For example, I know of: if (is_file("$myImagePath/$myImageName")) { // FIND MIME TYPE BUT HOW I DUNNO } The...
3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
9
by: arenaTR | last post by:
I'd like to put a logo in the titlebar of my webpage. The one I'm talking about is the one that's next to the URL in the address bar in both netscape and IE. Just so I'm clear, for example, on...
7
by: Dobedani | last post by:
Dear All, I am developing / maintaining a web application which generates GIF images on the fly. When I send the image, I make sure a header is sent first with MIME-type image/gif. My HTML-code...
0
by: doffer | last post by:
I want to make a portfoliosystem where user can register and get their own portfolio... I've started the developer work, but I'm stuck on the image upload part... I'm experiencing some problems...
3
by: ACaunter | last post by:
Hi there, I was wondering if there was a way to crop a peice of an ASP.Net Image, allowing the user to zoom in on only a section of the picture?? any help would be appreciated!! thanks --...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
2
by: Adam Teale | last post by:
hey guys Is there a builtin/standard install method in python for retrieving or finding out an image's dimensions? A quick google found me this:...
7
by: xx75vulcan | last post by:
Hi, I've got a PHP Upload Form that works great, unless that is, the image your uploading has been modified through a photo editing software. Example: if I upload the image straight from a...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.