1
0
Fork 0
This commit is contained in:
Chenx221 2024-01-22 11:56:57 +08:00
parent f89f3433f9
commit c07e554646
8 changed files with 72 additions and 0 deletions

1
13.test2.php Normal file
View File

@ -0,0 +1 @@
<?php

1
13.test3.php Normal file
View File

@ -0,0 +1 @@
<?php

1
13.test4.php Normal file
View File

@ -0,0 +1 @@
<?php

1
13.test5.php Normal file
View File

@ -0,0 +1 @@
<?php

1
13.test6.php Normal file
View File

@ -0,0 +1 @@
<?php

1
13.work1.php Normal file
View File

@ -0,0 +1 @@
<?php

65
13.work2.php Normal file
View File

@ -0,0 +1,65 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test1</title>
</head>
<body>
<form name="uploader" action="" method="post" enctype="multipart/form-data">
<table>
<tr>
<td>
上传文件1:
</td>
<td>
<input type="file" name="upload_file[]" id="upload1">
</td>
</tr>
<tr>
<td>
上传文件2:
</td>
<td>
<input type="file" name="upload_file[]" id="upload2">
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<input type="submit" value="上传" name="submit">
</td>
</tr>
</table>
</form>
<?php
$size_limit = 64* 1024 * 1024; // limit 64MB
$target_path = 'upload/';
if (!empty($_FILES['upload_file']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
// foreach ($_FILES['upload_file'] as $name => $value){
// echo $name.':'.$value.'<br>';
// }
//get upload file number
$ufile = $_FILES['upload_file'];
$n = count($ufile['name']);
for ($i=0;$i<$n;$i++){
if ($ufile['size'][$i] < $size_limit && $ufile['size'][$i] > 0) {
// check target file is exist, if exist just skip move and echo info
if (file_exists($target_path.$ufile['name'][$i])){
echo '文件'.$ufile['name'][$i].'已存在<br>';
continue;
}
move_uploaded_file($ufile['tmp_name'][$i],$target_path.$ufile['name'][$i]);
echo '文件'.$ufile['name'][$i].'上传成功<br>';
} else {
echo '错误,文件'.$ufile['name'][$i].'过大或为空<br>';
}
}
// $ufile = $_FILES['upload_file'];
// if ($ufile['size'] < $size_limit && $ufile['size'] > 0) {
// move_uploaded_file($ufile['tmp_name'],$target_path.$ufile['name']);
// echo '文件上传成功';
// } else {
// echo '错误,文件过大或为空';
// }
}
?>
</body>

1
data/07.txt Normal file
View File

@ -0,0 +1 @@
柔情似水 佳期如梦 忍顾鹊桥归路 两情若是久长时 又岂在朝朝暮暮