Hi to all,
Here is my code, I want upload file which are only images. All images with jpg, JPG, jpeg, JPEG, gif are uploaded successfully except with bmp file.
Plz, help me to find out the prob. why my code is fail with bmp extension file.
//file-detail-complex.php
<?php
$title = $_POST['title'];
$image = $_FILES['file']['name'];
$ext = explode('.',$image);
$size = $_FILES['file']['size'];
$a=array("jpg","jpeg","JPG","JPEG","png","gif","GIF","bmp","BMP");
$submit = $_POST['submit'];
if((in_array($ext[1],$a)) && ($size<=20000) && !empty($submit))
{
echo "File is correct!";
echo "<br/>";
echo "Image :".$image;
echo "<br/>";
echo "Extention :".$ext[1];
echo "<br/>";
echo "Size :".$size;
echo "<br/>";
if(file_exists("upload-img/" .$image))
{
echo "file already exist!";
}
else
{
$upload=move_uploaded_file($_FILES["file"]["tmp_name"], "upload-img/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload-img/" . $_FILES["file"]["name"];
}
}
else
{
echo "Please check the extension and size of the file!";
echo "<br/>";
}
?>
<body>
<form action="file-detail-complex.php" method="post" enctype="multipart/form-data">
Title:<input type="text" name="title" id="title" />
Image :<input type="file" name="file" id="file" />
<input type="submit" name="submit" value="submit" id="submit" />
</form>
</body>