0

I writing a php code to upload a image This code gives a error

<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["blogimage"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
if(isset($_POST["ok"])) {
  $check = getimagesize($_FILES["blogimage"]["tmp_name"]);
  if($check !== false) {
    echo "File is an image - " . $check["mime"] . ".";
    $uploadOk = 1;
  } else {
    echo "File is not an image.";
    $uploadOk = 0;
  }
}
?>

This is the error. Please Help Me

 Notice: Undefined index: blogimage in C:\MAMP\htdocs\shilalipi\admin\addnew.php on line 62
  • `$_FILES["blogimage"]` will only exist if the form is submitted and the file is added. – Markus AO Jul 27 '20 at 19:45
  • Specifically, duplicate of: [file upload php $_FILES undefined index error](https://stackoverflow.com/questions/21271060/file-upload-php-files-undefined-index-error) – Markus AO Jul 27 '20 at 19:51

0 Answers0