This is the error coming on browser console.
Notice: Undefined index: name in C:\wamp64\www\roomdhundhoo\roomdhundho\owner\test.php on line 3
My HTML Code.
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Image upload</title>
</head>
<body>
<form class="" action="test.php" method="post" enctype="multipart/form-data">
<input type="file" name="pic" id="pic" value="">
<input type="submit" name="submit" value="Get image">
</form>
</body>
</html>
When i am trying to upload file using $_FILES['pic']['name'] function, it is showing that 'name' index is not defined.
My PHP Code.
<?php
if(isset($_POST["submit"])) {
$file_name=$_FILES["pic"]["name"];
}
?>
When i tried this code:-
<?php
if(isset($_POST["submit"])) {
$file_name = basename($_FILES['pic']['name']);
}
?>
Same error is coming.
My code is successfully displaying file name directly. This means that PHP file is recognising that file has been submitted.
CODE
<?php
if(isset($_POST["submit"])) {
$file_name = $_POST['pic'];
echo $file_name;
}
?>
OUTPUT
Screenshot (29).png
This is the file name, which i uploaded.
Aucun commentaire:
Enregistrer un commentaire