我已将php.ini
文件中的配置更改为:
upload_max_size=100MB;
file_uploads is also ON;
但是以下代码在Windows本地服务器XAMPP上运行正常。相同的脚本允许将任何文件大小上载到数据库。在Linux中仅限于1 MB。
我还检查了my.cnf
文件,但没有选项允许在Windows my.ini
文件中提供最大数据包大小。
// This is the temporary place where it got put on the server
// after it was uploaded
$tempfile = $_FILES["uploadedfile$i"]["tmp_name"] ;
// addslashes so as not to break anything :)
if(!empty($tempfile)){
//$data = addslashes(fread(fopen($tempfile, "rb"), filesize($tempfile)));
$data = addslashes(fread(fopen($tempfile, "rb"),filesize($tempfile)));
$fp = fopen($_FILES["uploadedfile$i"]['tmp_name'], 'rb');
}
// pull out useful bits in case they are needed.
$filetype = $_FILES["uploadedfile$i"]["type"];
$filesize = $_FILES["uploadedfile$i"]["size"];
$filename = $_FILES["uploadedfile$i"]["name"];
这是将文件上传到数据库的命令:
$query=$this->db->prepare("insert into $table
(filename,data,filexml,filesize,filetype,filetype1,category,filesize1)
values (?,?,?,?,?,?,?,?)");
$query->bindValue(1,$filename,PDO::PARAM_STR);
$query->bindParam(2,$fp,PDO::PARAM_LOB);
$query->bindValue(3,$filexml,PDO::PARAM_STR);
$query->bindValue(4,$filesize,PDO::PARAM_STR);
$query->bindValue(5,$filetype,PDO::PARAM_STR);
$query->bindValue(6,$filetype1,PDO::PARAM_STR);
$query->bindValue(7,$_SESSION['radbut'],PDO::PARAM_STR);
$query->bindValue(8,$filesize1,PDO::PARAM_INT);
$query->execute();
echo $table;
echo 'wav eee upload successful';
答案 0 :(得分:0)
我们没有足够的有关您的配置的信息来完全帮助您,但以下是您可以遵循的一些线索:
post_max_size
文件的php.ini
。php.ini
中设置的参数是否已成功设置到phpinfo()
中(确保它未被Apache覆盖)suhosin
,请检查其参数,有时可能会很棘手suhosin
错误的系统日志信息)max_allowed_packet
MySQL配置上的my.cnf
。正如迈克所指出的,MySQL不是为存储大文件而设计的。