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
YT_Xaos
November 23, 2023, 2:51pm
2
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.
Errors when accessing temporary folders (WordPress & PHP Upload errors)
Accessing the temporary directory, commonly used by WordPress and PHP when managing uploaded files, is failing.
Which components are affected by this issue
WordPress plugin installation
WordPress update
PHP File upload applications
What issues may you see
“Temporary Directory not available”
“Failed to open stream: no such file or directory”
When will this issue be resolved
We are doing our best to get these issues resol…
Cheers!
5 Likes
SoftHub
November 23, 2023, 9:45pm
6
Working for me! Is it resolved for everybody?
3 Likes
brianf
November 23, 2023, 10:30pm
7
It started working for me too
2 Likes
Issue is resolved now. It started working for me too.
system
Closed
December 1, 2023, 3:16am
9
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.