Skip to content

Instantly share code, notes, and snippets.

@PUSRISTEK
Created November 18, 2016 01:54
Show Gist options
  • Save PUSRISTEK/752d9c12fa43a30a45dd7d261cb39095 to your computer and use it in GitHub Desktop.
Save PUSRISTEK/752d9c12fa43a30a45dd7d261cb39095 to your computer and use it in GitHub Desktop.
PHP - Check Fake Image File
$target_dir = "upload-folder/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
if(isset($_POST["submit"])) {
$check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
if (exif_imagetype($_FILES["fileToUpload"]["tmp_name"]) != IMAGETYPE_JPEG) {
echo 'File bukan gambar asli..';
$uploadOk = 0;
} else {
$uploadOk = 1;
echo "File Berhasil diupload" . $target_file ;
echo "MIME : " . $check["mime"] . ".";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment