PHP check if file is image php - Net-Raft.com

Welcome aboard! We are happy you are here and wish you good net-raft!




Just a Web Code Solution

check if file is an image php


 645

Show ResultPHP


1

<!DOCTYPE html>
<html>
<body>

<form action="<?php echo $_SERVER['PHP_SELF'];?>" id ="upl1" method="POST" enctype="multipart/form-data">
<input type="file" id="html_btn1" name="html_btn1"></p>
<button type="submit" form="upl1" value="Submit">Submit</button>
</form>

<?php

if ($_SERVER["REQUEST_METHOD"] == "POST") {

$check = getimagesize($_FILES["html_btn1"]["tmp_name"]);

if($check !== false) {

echo "File is an image - " . $check["mime"] . ".";

} else {

echo "File is not an image.";

}

}

?>

</body>
</html>


By        
The power of the user (%)
52%



The most helpful PHP solutions

detect browser phpdetect browser phpPHP

Click to see more ...

  4.4K     408

create QR code phpcreate QR code phpPHP

Click to see more ...

  2.9K     289

create relative date phpcreate relative date phpPHP

Click to see more ...

  1.9K     254

drag and drop upload file using phpdrag and drop upload file using phpPHP

Click to see more ...

  2.4K     253

delete array item phpdelete array item phpPHP

Click to see more ...

  2.3K     239

detect ie phpdetect ie phpPHP

Click to see more ...

  1.5K     213

get meta tag phpget meta tag phpPHP

Click to see more ...

  1.3K     193

get current url phpget current url phpPHP

Click to see more ...

  1.2K     191

detect speed internet phpdetect speed internet phpPHP

Click to see more ...

  1.1K     176

Get real client country using php ?Get real client country using php ?PHP

Click to see more ...

  1K     173