Saturday, August 13, 2011

Simple Trick to Find File Content Type in PHP

When processing file from server side we need a Exact document Content-Type header define required to process a content type properly.

From the following php header parameter have "Content-Type": audio/mpeg. The String "audio/mpeg" is the content type of the file which we need to process a proper format disposition from server to client.

header('Content-type: audio/mpeg');
Here is the Simple Trick to find the document Content-Type header string

	echo "<pre>";
	echo "</pre>";

<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Simple Trick to Find File Content Type in PHP</title>

<form id="form1" name="form1" method="post" action="<?=$_SERVER['PHP_SELF']?>" enctype="multipart/form-data">

<input name="filename" type="file" />
<input type="submit" name="upload" value="Check Content Type" />


No comments:

Post a Comment