大家可以通过下面这一段代码, 来具体了解 PHP 批量上传图片的具体方式我们在学习 PHP 的时候, 肯定是要从实际操作中慢慢积累经验, 以巩固我们所学到的知识, 逐渐的加强我们的编程水平
PHP 保护文件系统的具体代码分享
PHP 保护数据库的具体代码示例
探讨主要的 PHP 应用领域
基于 PHP 的 AJAX 技术的具体应用解析
PHP 限制上传文件大小的具体解决办法
PHP 批量上传图片的代码如下:
- <html>
- <head><title>upload picture more once</title></head>
- <body>
- <form action=""method="post"enctype="multipart/form-data">
- <p>Pictures:<br />
- <input type="file" name="pictures[]" /><br />
- <input type="file" name="pictures[]" /><br />
- <input type="file" name="pictures[]" /><br />
- <input type="submit" name="upload" value="Send" />
- </p>
- </form>
- </body>
- </html>
- <?php
- if($_POST['upload']=='Send'){
- $dest_folder = "picture/";
- if(!file_exists($dest_folder)){
- mkdir($dest_folder);
- }
- foreach ($_FILES["pictures"]["error"] as $key => $error) {
- if ($error == UPLOAD_ERR_OK) {
- $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
- $name = $_FILES["pictures"]["name"][$key];
- $uploadfile = $dest_folder.$name;
- move_uploaded_file($tmp_name, $uploadfile);
- }
- }
- }
- ?>
来源: https://www.php1.cn/detail/php-420abcafa5.html