What are MIME types?
Enquire Now

What are MIME types?

What are MIME types?

 Amrit Pal Singh  02-02-2018  Website  Website Designing

Full form of MIME is Multipurpose Internet Mail Extensions. It is basically the file type, in other words format of the file. If we take an example of an image, its type can be of “png”,”jpg” etc. These are known as file extension but on web we have to specify about it as “image/png”, “image/jpeg” this tell specifically about the type of file you are downloading, uploading or using for some other purposes. Web developers also uses these mime type for validating file type that the user is uploading.

Some of the common MIME Types are:

MIME Type of Image, PNG, JPG, JPEG, GIF

PNG     -           image/png

JPG     -           image/jpeg

JPEG   -           image/jpeg

GIF      -           image/gif

MIME type for MS Word, PDF, Power Point, Excel and Notepad

DOC    -           application/msword

DOCX    -         application/vnd.openxmlformats-officedocument.wordprocessingml.document

PDF     -           application/pdf

PPT     -           application/mspowerpoint

CSV     -           text/csv

XLSX   -           application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

XLS      -           application/

TXT     -           text/plain


How to upload a file with HTML?

Normally we use a “form” tag with attributes such as “action (the page on which you want to redirect when a person clicks on submit button”, “method – post or get”. To upload any file on server you have to add an additional attribute “enctype= multipart/form-data”. It is a mandatory attribute for uploading purpose but if you are uploading your file through jQuery, you need not to worry about the attribute. Without attribute “enctype= multipart/form-data” you can upload your file to server.

How to upload a file with PHP?

When you have submitted a request on server through HTML, now you have to get values. In case of normal fields such as text, date, checkbox you can use GET or POST method as per your need but for the “file” you have to use

$_FILES[‘file_name’][‘name’] to get the name of the file.

To get the size you can use $_FILES[‘file_name’][‘size’] and for validation purposes you may require to validate your file type with the MIME type. So, for that you can use



Futher to have to create temporary file on the server so for that you have to use


After creating you have to move your file to a particular dirtory on the server. You can do it by using  a simple function

$uploaddir = '/var/www/uploads/';

$uploadfile = $uploaddir . basename($_FILES[file_name’]['name']);

move_uploaded_file($_FILES[file_name]['tmp_name'], $uploadfile).


Recent Blogs