0

Use of undefined constant fileError - assumed 'fileError' (this will throw an Error in a future version of PHP) in C:\xampp\htdocs\test\upload.php on line 17 There was an error uploading your files

<?php 

if(isset($_POST['submit'])){
        $file = $_FILES['file'];
        $fileName = $_FILES['file']['name'];
        $fileTmpName = $_FILES['file']['tmp_name'];
        $fileSize = $_FILES['file']['size'];
        $fileError = $_FILES['file']['error'];
        $fileType = $_FILES['file']['type'];

        $fileExt = explode('.', $fileName);
        $FileActualExt = strtolower(end($fileExt));

        $allowed = array('jpg', 'jpeg', 'png', 'pdf');

if(in_array($FileActualExt, $allowed)){
if(fileError === 0){
if ($fileSize < 500000000){
$FileNameNew = uniqid('', true).".".$FileActualExt;
$FileDestination = 'uploads/'.$fileNameNew;
move_uploaded_file($fileTmpName, $fileDestination);
header('Location: index.php?uploadsuccess');    
} else {
echo "Your file was too big";
}   
} else {
 echo "There was an error uploading your files";
}   
} else {
echo "You can't upload files of this type"; 
}
}
?>
<form action="upload.php" method="POST" enctype="multipart/form-data">
    <input type="file" name="file">
    <button type="submit" name="submit">Upload</button>

What's the proper code to solve the error?

Touheed Khan
  • 2,149
  • 16
  • 26
Pj Mischuk
  • 31
  • 5

1 Answers1

0

Try to change

if(fileError === 0){

to

if($fileError === 0){