Magic Cars
Description
Analysis
<?php error_reporting(0); ?>
<?php
$files = $_FILES["fileToUpload"];
$uploadOk = true;
if ($files["name"] != "") {
$target_dir = urldecode("images/" . $files["name"]);
if (strpos($target_dir, "..") !== false) {
$uploadOk = false;
}
if (filesize($files["tmp_name"]) > 1 * 1000) {
$uploadOk = false;
echo "too big!!!";
}
$extension = strtolower(pathinfo($target_dir, PATHINFO_EXTENSION));
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$type = finfo_file($finfo, $files["tmp_name"]);
finfo_close($finfo);
if ($extension != "gif" || strpos($type, "image/gif") === false) {
echo " Sorry, only gif files are accepted";
$uploadOk = false;
}
$target_dir = strtok($target_dir, chr(0));
if ($uploadOk && move_uploaded_file($files["tmp_name"], $target_dir)) {
echo "<a href='$target_dir'>uploaded gif here go see it!</a>";
}
}
?>Solution
Last updated