<?php
if(isset($_POST["act"]))
{
echo count($_FILES["userinfo"]["name"]) . "<br />";
print_r($_FILES["userinfo"]);
foreach($_FILES["userinfo"]["size"] as $val)
{
echo ReplaceArray($val) . "<br />";
}
for($i=0;$i<count($_FILES["userinfo"]["name"]);$i++)
{
if(move_uploaded_file($_FILES["userinfo"]["tmp_name"][$i],ReplaceArray($_FILES["userinfo"]["name"][$i])))
{
echo $_FILES["userinfo"]["name"][$i] . " upload success! <br />";
}
}
}
function ReplaceArray($name)
{ // function for replace quotes in image
$name=str_replace(' ','_',$name);
$name=str_replace("'",'_',$name);
return ($name);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<form action="<?php echo $_SERVER["PHP_SELF"]?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="act" value="upload" />
<input type="file" name="userinfo[]" />
<input type="file" name="userinfo[]" />
<input type="file" name="userinfo[]" />
<input type="submit" value="submit" />
</form>
<?php
$str = "wo men shi <b>chens</b>.";
echo htmlentities($str); //output wo men shi <b>chens</b>.
?>
</body>
</html>