Rohit Rohit - 4 years ago 122
PHP Question

upload file to web server error 6 php

I am trying to upload a file from a php form.It wont work on linux server. I want it to move it to a subdir '/uploads' from where the file is.

I get the below error when executing the page by

to get the error number.

It returns :

Upload failed with error code 6

Does anyone know what this error stands for?

Form Code :

<!DOCTYPE html>

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


upload.php :


if($_FILES['file_upload']['name'] != "" )
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["file_upload"]["name"]);
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
$uploadOk = 1;
die("No file specified!");

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

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

// Allow certain file formats
if($imageFileType != "txt" && $imageFileType != "xls" && $imageFileType != "xlsx")
echo "Sorry, only TXT, XLS, XLSX files are allowed.";
$uploadOk = 0;

if ($_FILES["file_upload"]['error'] !== UPLOAD_ERR_OK) {
die("Upload failed with error code " . $_FILES['file_upload']['error']);
// 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["file_upload"]["tmp_name"], $target_file)) {
echo "The file ". basename( $_FILES["file_upload"]["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";

I already search for this problem and find the solution Here. But not undestand properly.

I also given full permission 777 to
Any help will be greatly appreciated. Thanks

Answer Source

Value: 6; Missing a temporary folder. Introduced in PHP 5.0.3.

Fix your settings..

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download