原文:https://www.cnblogs.com/jc2182/p/11582421.html
原文:https://blog.csdn.net/Jokenzhang/article/details/105675061
文件上传测试代码
<?php
if(isset($_FILES['image'])){
$errors= array();
$file_name = $_FILES['image']['name'];
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type'];
$name_arr = explode('.',$_FILES['image']['name']);
$file_ext=strtolower(end($name_arr));
if(empty($errors)==true) {
/* 把图片从临时文件夹内的文件移动到当前脚本所在的目录 */
move_uploaded_file($file_tmp,"./".$file_name);
echo "成功上传";
}else{
print_r($errors);
}
}
?>
<html>
<body>
<!-- action 默认为当前脚本 -->
<form action = "" method = "POST" enctype = "multipart/form-data">
<input type = "file" name = "image" />
<input type = "submit" name="提交" />
<ul>
<li>文件名: <?php echo isset($_FILES['image']['name']) ? $_FILES['image']['name'] : '' ; ?>
<li>文件大小: <?php echo isset($_FILES['image']['size']) ? $_FILES['image']['size'] : '' ; ?>
<li>文件类型: <?php echo isset($_FILES['image']['type']) ? $_FILES['image']['type'] : '' ; ?>
</ul>
</form>
</body>
</html>
大文件上传问题解决
环境
win10
phpStudy 8.1.0.6
apache 2.4.39
解决方案
PHP配置
文件路径:C:phpstudy_proExtensionsphpphp7.3.4ntsphp.ini
修改的配置项:
- upload_max_filesize=100M
- post_max_size=100M
Apache配置
文件路径:C:phpstudy_proExtensionsApache2.4.39confhttpd.conf
修改的配置项:
- FcgidMaxRequestLen 512000000
这里相当于(约等于)500M