tmp_dir is set
open_basedir includes tmp_dir path
Still I get file upload error 6.
Any guess?
file upload error 6
Moderator: General Moderators
Re: file upload error 6
hai,
print "<td style='height:40px;'><input type=file bgcolor=white name='files[]' id='files[]' size=60 ></input> </td>";
while(list($key,$value) = each($_FILES['files']['name']))
{
if(!empty($value))
{ // this will check if any blank field is entered
$filename = $value; // filename stores the value
//$filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line
$add = "upload/$filename"; // upload directory path is set
print "<script>alert('path is set');</script>";
//echo $_FILES[images][type][$key]; // uncomment this line if you want to display the file type
// echo "<br>"; // Display a line break
copy($_FILES['files']['tmp_name'][$key], $add); // upload the file to the server
chmod("$add",0777); // set permission to the file.
}
$path='upload'.'\\'.$filename;
}
Try this Code.
Upload is a folder, which is same dir.
print "<td style='height:40px;'><input type=file bgcolor=white name='files[]' id='files[]' size=60 ></input> </td>";
while(list($key,$value) = each($_FILES['files']['name']))
{
if(!empty($value))
{ // this will check if any blank field is entered
$filename = $value; // filename stores the value
//$filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line
$add = "upload/$filename"; // upload directory path is set
print "<script>alert('path is set');</script>";
//echo $_FILES[images][type][$key]; // uncomment this line if you want to display the file type
// echo "<br>"; // Display a line break
copy($_FILES['files']['tmp_name'][$key], $add); // upload the file to the server
chmod("$add",0777); // set permission to the file.
}
$path='upload'.'\\'.$filename;
}
Try this Code.
Upload is a folder, which is same dir.
Re: file upload error 6
This solution does not work because 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.
I get the error right at $_FILES.
Array ( [userfile] => Array ( [name] => test.txt [type] => [tmp_name] => [error] => 6 [size] => 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?
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.
I get the error right at $_FILES.
Array ( [userfile] => Array ( [name] => test.txt [type] => [tmp_name] => [error] => 6 [size] => 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?
Re: file upload error 6
http://ca3.php.net/manual/en/features.f ... errors.php
And guys, use [ code=php ] tags - most people don't even bother reading code unless it's properly formatted. I know I didn't.
And guys, use [ code=php ] tags - most people don't even bother reading code unless it's properly formatted. I know I didn't.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.