php - 输入类型=文件不能接受大尺寸图片
问题描述
我想使用输入类型=“文件”上传任何大小的图像。我目前正在尝试上传 2-3 MB 的图像,但它不起作用,并且其他表单数据也没有显示在数据库中。
我目前在我的表单中使用此代码进行图片上传:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="row">
<div class="col-md-3 col-lg-3 col-xs-12 col-sm-12 upload2">
<img id="file1" width="150" height="80">
<input type="file" name="a_image[]" required id="imgupload" style="display:none" onChange="document.getElementById('file1').src = window.URL.createObjectURL(this.files[0])">
<br>
<a href="#" class="upload" onclick="$('#imgupload').trigger('click'); return false;"> <i class="fa fa-upload" aria-hidden="true"></i> Upload </a>
</div>
<div class="col-md-3 col-lg-3 col-xs-12 col-sm-12 upload2">
<img id="file2" width="150" height="80">
<input type="file" name="a_image[]" id="imgupload1" style="display:none" onChange="document.getElementById('file2').src = window.URL.createObjectURL(this.files[0])">
<br>
<a href="#" class="upload" onclick="$('#imgupload1').trigger('click'); return false;"><i class="fa fa-upload" aria-hidden="true"></i> Upload </a>
</div>
<div class="col-md-3 col-lg-3 col-xs-12 col-sm-12 upload2">
<img id="file3" width="150" height="80">
<input type="file" name="a_image[]" id="imgupload2" style="display:none" onChange="document.getElementById('file3').src = window.URL.createObjectURL(this.files[0])">
<br>
<a href="#" class="upload" onclick="$('#imgupload2').trigger('click'); return false;"><i class="fa fa-upload" aria-hidden="true"></i> Upload </a>
</div>
<div class="col-md-3 col-lg-3 col-xs-12 col-sm-12 upload2">
<img id="file4" width="150" height="80">
<input type="file" name="a_image[]" id="imgupload3" style="display:none" onChange="document.getElementById('file4').src = window.URL.createObjectURL(this.files[0])">
<br>
<a href="#" class="upload" onclick="$('#imgupload3').trigger('click'); return false;"><i class="fa fa-upload" aria-hidden="true"></i> Upload </a>
</div>
</div>
在模型页面上
$id = $a_id;
$i = 0;
foreach($_FILES['a_image']['tmp_name'] as $key => $tmp_name)
{
$i++;
$file_tmp =$_FILES['a_image']['tmp_name'][$key];
move_uploaded_file($file_tmp,"template/uploads/product/ad_".$id."_".$i.'.jpg');
$source_path = "template/uploads/product/ad_".$id."_".$i.".jpg";
$thumb_path = 'template/uploads/product/thumb/ad_'.$id.'_'.$i.'.jpg';
$this->upload_thumbnail($source_path,$thumb_path,'200','200');
}
解决方案
我相信输入类型文件的默认最大大小是20 兆字节。
要改变这个...
.htaccess
如果创建php.ini
具有相似值的代码,请将以下代码添加到您的代码中。
php_value post_max_size 100M
php_value upload_max_filesize 100M
php_value memory_limit 64M
它可能不起作用,但无论如何都要尝试一下!
推荐阅读
- javascript - 如何从javascript和python中的数组生成和总结随机数
- angular - 组件请求时获取请求返回订阅者
- sql - 当结果已被过滤以匹配我的日期格式(Oracle SQL)时,为什么这个 to_date 不起作用
- c - 管道的解释
- shell - 使用 unix shell 脚本/Python 解析 json 类型的文件以找出特定值
- python - 尝试使用 vscode 在 anaconda(python 3.8.5)中没有已知父包的相对导入
- sql-server - Perl 与 mssql 服务器的连接
- python - 如何使此代码在 Tkinter 中用于多项选择测验?
- html - 当父 div 包含特定单词时从 HTML 中提取值(多嵌套 div)
- linux - Bash 脚本:我的减法问题