提供一个基础教程了,告诉你如果利用move_uploaded_file函数来实现多图片上传了,当然也可以实现多文件上传操作了,希望对你有帮助。
- <html>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <head>
- <title>多文件上传</title>
- </head>
- <body>
- <form accept="" method="post" enctype="multipart/form-data">
- <input type="file" name="img[]" /><br />
- <input type="file" name="img[]" /><br />
- <input type="file" name="img[]" /><br />
- <input type="file" name="img[]" /><br />
- <input type="file" name="img[]" /><br />
- <input type="file" name="img[]" /><br />
- <input type="submit" name="s" /><br />
- </form>
- <?php
-
- $img = $_FILES['img'];
- if ($img)
- {
-
- $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 "<img src='$filename' alt='$filename' /> ";
- }
- }
- $i++;
- }
- }
- ?>
- </body>
- </html>
|