Created
November 18, 2016 01:54
-
-
Save PUSRISTEK/752d9c12fa43a30a45dd7d261cb39095 to your computer and use it in GitHub Desktop.
PHP - Check Fake Image File
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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