So I have my image upload script and it seems to be working just fine except for when I try to upload a .bmp file then it get that the file is not an image.
<?php
public function addimage()
{
$this->data['title'] = $this->config->item('title')." - Process Add Image";
$this->data['errors'] = array();
if( $this->session->userdata('user') )
{
// Process image and add to database.
$type = $_POST['gallery'];
if( !$_FILES['image']['size'] > 1 ) $this->data['errors'][] = "Filesize error. Error Code #7101";
// Set dir & thumb dir, create if not there
$dir = $this->config->item('upload_path')."". date("mY",time());
if( !is_dir($dir) ) mkdir($dir);
$tndir = $dir ."\\thumbs";
if( !is_dir($tndir) ) mkdir($tndir);
$ext = pathinfo($_FILES["image"]['name']);
$ext = $ext['extension'];
$filename = microtime(TRUE);
$temp = $dir ."\\{$filename}temp.{$ext}";
$pic = $dir ."\\{$filename}.{$ext}";
$tn = $tndir ."\\{$filename}.{$ext}";
if( !@getimagesize($_FILES["image"]['tmp_name']) ) $this->data['errors'][] = "File is not an image. Error Code #7102";
if( !move_uploaded_file($_FILES["image"]['tmp_name'],$temp) ) $this->data['errors'][] = "File unabled to be moved. Error Code #7104";
if( sizeof($this->data['errors']) > 0 )
{
$this->load->view('global/errors',$this->data);
return;
}
if( !$this->_imageResize($temp,$tn,"45","60",TRUE) ) $this->data['errors'][] = "Thumbnail resize failed. Error Code #7111";
if( !$this->_imageResize($temp,$pic,"500","700") ) $this->data['errors'][] = "View resize failed. Error Code #7112";
if( !unlink($temp) ) $this->data['errors'][] = "Temporary file deletion failed. Code #7113";
if( sizeof($this->data['errors']) > 0 )
{
$this->load->view('global/errors',$this->data);
return;
}
if( !$this->gallery->insertImage($type,$filename,$ext) )
{
$this->data['errors'][] = "Error inserting into database. Error Code #7121";
$this->load->view('global/errors',$this->data);
return;
} else
{
$this->data['message'] = "Image Successfully Uploaded";
}
$this->data['galleries'] = array();
$result = $this->gallery->getGalleries();
foreach($result->result() as $row)
{
$this->data['galleries'][$row->id] = $row->name;
}
$this->load->view("gallery/image_form",$this->data);
} else
{
$this->data['errors'][] = "You must be logged in to view this page. Error code #5000";
header("Refresh: 5;url: ". $_SERVER['HTTP_HOST'] ."/");
$this->load->view('global/errors',$this->data);
}
}
It works perfectly for jpg, gif and png files however it does not work for bmp files. It is triggering the error from this line:
if( !@getimagesize($_FILES["image"]['tmp_name']) ) $this->data['errors'][] = "File is not an image. Error Code #7102";
Any thoughts? I'm lost as to why its not working for bmp file. Granted I can always save to a different format in photoshop, but if I want to use it for a more public use it'd be nice to accept bmp too.