Home  >  Article  >  php教程  >  多图片上传的php代码

多图片上传的php代码

WBOY
WBOYOriginal
2016-06-13 10:03:441065browse

提供一个基础教程了,告诉你如果利用move_uploaded_file函数来实现多图片上传了,当然也可以实现多文件上传操作了,希望对你有帮助。

提供一个基础教程了,告诉你如果利用move_uploaded_file函数来实现多图片上传了,当然也可以实现多文件上传操作了,希望对你有帮助。




多文件上传


















//上传文件信息
$img = $_FILES['img'];
if ($img)
{
//文件存放目录,和本php文件同级
$dir = dirname(__file__);
$i = 0;
foreach ($img['tmp_name'] as $value)
{
$filename = $img['name'][$i];
if ($value)
{
$savepath="$dir$filename";
$state = move_uploaded_file($value, $savepath);
//如果上传成功,预览
if($state)
{
echo "$filename ";
}
}
$i++;
}
}
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn