PHP UPLOAD_ERR_NO_TMP_DIR Unable to upload files

I am unable to upload files on my website impleca.tech . To check if its an issue in my code I have created an other subdomain with a simple file upload script, Are the same issue is happening there.

Website URL

Used to test file upload
https://test.impleca.tech/uploader.php

Error Message

File upload error 6 UPLOAD_ERR_NO_TMP_DIR

Other Information

Array
(
    [fileToUpload] => Array
        (
            [name] => images.jpg
            [full_path] => images.jpg
            [type] => 
            [tmp_name] => 
            [error] => 6
            [size] => 0
        )

)
1 Like

Could you show us the full code you are working with?

2 Likes

There seems to be a problem with the tmp folder being inaccessible.

5 Likes
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

echo "<pre>";
print_r($_FILES);
echo "</pre>";

$target_dir = "./uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));


  // Check if file has been uploaded
  if (!empty($_FILES["fileToUpload"]["tmp_name"])) {
    $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    if($check !== false) {
      echo "File is an image - " . $check["mime"] . ".";
      $uploadOk = 1;
    } else {
      echo "File is not an image.";
      $uploadOk = 0;
    }
  } else {
    echo "No file uploaded.";
    $uploadOk = 0;
  }

// Check if file already exists
if (file_exists($target_file)) {
  echo "Sorry, file already exists.";
  $uploadOk = 0;
}

// Check file size
if ($_FILES["fileToUpload"]["size"] > 500000) {
  echo "Sorry, your file is too large.";
  $uploadOk = 0;
}

// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
&& $imageFileType != "gif" ) {
  echo "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";
  $uploadOk = 0;
}

// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
  echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
  if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
    echo "The file ". htmlspecialchars( basename( $_FILES["fileToUpload"]["name"])). " has been uploaded.";
  } else {
    echo "Sorry, there was an error uploading your file.";
  }
}
?>

<!DOCTYPE html>
<html>
<body>

<form action="uploader.php" method="post" enctype="multipart/form-data">
  Select image to upload:
  <input type="file" name="fileToUpload" id="fileToUpload">
  <input type="submit" value="Upload Image" name="submit">
</form>

</body>
</html>

Hi shrigonda,

It might not be your fault.

Cheers!

5 Likes

Working for me! Is it resolved for everybody?

3 Likes

It started working for me too :smiley:

2 Likes

Issue is resolved now. It started working for me too.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.