选择语言 :

 Core_Upload::is_image

验证是否图片

bool Core_Upload::is_image( )
返回值
  • bool
File: ./core/classes/upload.class.php
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
public function is_image()
{
    $png_mimes  = array('image/x-png');
    $bmp_mimes  = array('image/bmp');
    $jpeg_mimes = array('image/jpg', 'image/jpe', 'image/jpeg', 'image/pjpeg');
 
    if (in_array($this->file['type'], $bmp_mimes))
    {
        $this->file['type'] = 'image/bmp';
    }
 
    if (in_array($this->file['type'], $png_mimes))
    {
        $this->file['type'] = 'image/png';
    }
 
    if (in_array($this->file['type'], $jpeg_mimes))
    {
        $this->file['type'] = 'image/jpeg';
    }
 
    $img_mimes = array
    (
        'image/gif',
        'image/jpeg',
        'image/png',
        'image/bmp',
    );
 
    return (in_array($this->file_type, $img_mimes, true)) ? true : false;
}