希望有人可以在这里帮助我。整夜浏览,我尝试的任何东西似乎都不起作用,但我是 php 新手,所以我很慢。我需要上传 6 张图片,这很好用。但后来我意识到您不仅可以上传图像,还可以上传所有其他文件类型。我试图能够将其限制为每个 100kb 以下的图像。嘻嘻嘻嘻嘻嘻嘻!!!请!
function findexts ($filename) { $filename = strtolower('$filename') ;
$exts = preg_split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
$ext = findexts ($_FILES['images']['name']) ;
$ran = rand ();
$ran2 = $ran.".";
while(list($key,$value) = each($_FILES['images']['name']))
{
if(!empty($value))
{
$filename = $ran.$value;
$filename=str_replace(" "," _ ",$filename);// Add _ inplace of blank space in file name, you can remove this line
$add = "media/".$ran."$filename";
$insert_query = "INSERT INTO ....VALUES ...";
//echo $_FILES['images']['type'][$key];
// echo "<br>";
copy($_FILES['images']['tmp_name'][$key], $add);
chmod("$add",0777);
mysql_query($insert_query);
}
}