Jump to content

Archived

This topic is now archived and is closed to further replies.

shalmoli

[SOLVED] file upload error TMP_DIR not found

Recommended Posts

In php.ini -

- tmp_dir is set

- open_basedir includes tmp_dir path

 

Still I get file upload error 6.

 

I guess there is some issue in the php.ini config.

 

I guess there are just 2 directives that interfere with file uploads - tmp_dir and open_base_dir.

Max size is 2M , so I guess there are no issues regarding file size as I am just trying to upload a testfile of 1KB.

 

I get the error right at $_FILES.

 

Array ( [userfile] => Array ( [name] => test.txt [type] => [tmp_name] => [error] => 6 => 0 ) )

 

I am posting the code and this code works in one server but not the other.

_________________________________________________________________________

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Upload Test</title>

</head>

<body>

<form enctype="multipart/form-data" action="upldtest.php" method="POST">

 

<!-- MAX_FILE_SIZE must precede the file input field -->

<input type="hidden" name="MAX_FILE_SIZE" value="99999999" />

 

<!-- Name of input element determines name in $_FILES array -->

Send this file: <input name="userfile" type="file" />

 

<input type="submit" value="Send File" />

</form>

</body>

</html>

 

 

 

<?php

 

$form_data = $_FILES['userfile']['tmp_name'];

print_r($_FILES);

 

//set the location

$base_name = $_SERVER['DOCUMENT_ROOT']."/uploads/".$form_data;

 

//move_uploaded_file($form_data, $base_name);

 

// upload the file to the server

if(copy($_FILES['userfile']['tmp_name'], $base_name)){

echo "upload successful";

}

else{

echo "Upload Failed";

}

 

?>

 

Any suggestions?

 

Share this post


Link to post
Share on other sites

what is temporary directory set to? It has to be path problem.

Share this post


Link to post
Share on other sites

Thanks for the reply.

I am copying the value of both the directives from phpinfo()

 

open_basedir /var/www/tor/projects/:/tmp/:/var/tmp/:/var/www/tor/tmp/:/var/lib/php5:/usr/share/php/ no value

 

upload_tmp_dir /var/www/tor/tmp/ no value

 

Do you think there are any other field in php.ini that influences the value?

 

 

Share this post


Link to post
Share on other sites

Remove the trailing forward slash from your temporary upload directory. Your open_basedir directive allows access to /var/www/tor/tmp/, so the temporary upload directory must be set to it's root, not to the directory it's self.

 

upload_tmp_dir   /var/www/tor/tmp

Share this post


Link to post
Share on other sites

Thanks a lot :-)

The issue was indeed the trailing slash in upload_tmp_dir.

The issue is resolved now.

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.