Page 1 of 1

file upload error 6

Posted: Fri Jan 30, 2009 4:49 am
by sdas
tmp_dir is set
open_basedir includes tmp_dir path
Still I get file upload error 6.

Any guess?

Re: file upload error 6

Posted: Fri Jan 30, 2009 5:28 am
by mubeena
hai,

print "<td style='height:40px;'><input type=file bgcolor=white name='files[]' id='files[]' size=60 ></input>&nbsp;</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

Posted: Fri Jan 30, 2009 5:51 am
by sdas
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?

Re: file upload error 6

Posted: Fri Jan 30, 2009 2:20 pm
by pickle
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.