[英]Handling file uploads larger than 10mb in PHP
I have this form 我有这个表格
<table class="table">
<div class="error"><?php if(!empty($errors))echo output_errors($errors);?></div>
<form action = "upload_music.php" method = "POST" enctype = "multipart/form-data">
<tr>
<td>Artist:</td>
<td><input type="text" name="artist" value=""></td>
</tr>
<tr>
<td>Track Name:</td>
<td><input type="text" name="track_name" value=""></td>
</tr><?php print_r($_FILES);?>
<tr>
<td>Genre:</td>
<td>
<?php
$genres = Genre:: getAllGenre();
?>
<select name = "genre">
<?php
for($i = 0 ; $i<count($genres);$i++){
?>
<option value = "<?php echo "{$i}"?>"><?php echo "{$genres[$i]['genre']}";?> </option>
<?php }
?>
</select>
</td>
</tr>
</tr>
<td>Track:</td>
<td><input type='file' name='file_path'></td>
</tr>
<tr>
<td>Track Description:</td>
<td><textarea name="track_desc" rows ="5"></textarea></td>
</tr>
<tr>
<td><input class="btn btn-success" type="submit" name = "submit" value="Upload"></td>
</tr>
<form>
</table>
Where the user will have to upload a track. 用户必须在哪里上传曲目。 every time I upload a file that is larger than 7mb the
print_r($_FILES);
每次我上传大于7mb的文件时,
print_r($_FILES);
prints an empty array. 打印一个空数组。 but when I upload a file that is below 8mb or an mp3 the
print_r($_FILES);
但是当我上传的文件小于8mb或mp3时,
print_r($_FILES);
prints an array with values. 打印带有值的数组。
I am guessing that the some file is not being read by $_FILES because their size is larger than 8mb? 我猜$ _FILES无法读取某些文件,因为它们的大小大于8mb? if that's the case How would I upload files that is larger than 8mb?
如果是这种情况,我将如何上传大于8mb的文件? also my php.ini settings with regards to POSt and FILE uploads looks like this
我关于POST和FILE上传的php.ini设置也像这样
post_max_size = 128M
upload_max_filesize = 128M
if you guys needed an extra information I am using XAMPP. 如果你们需要额外的信息,我正在使用XAMPP。
It looks like you are looking into wrong php.ini because the default post_max_size is generally 8M. 看来您正在寻找错误的php.ini,因为默认的post_max_size通常为8M。
Restart the web server and look into phpInfo() 重新启动Web服务器并查看phpInfo()
You can easily just override the ini in your PHP with this code. 您可以使用此代码轻松地在PHP中覆盖ini。
ini_set('memory_limit', '32M');
ini_set('post_max_size', '16M');
ini_set('upload_max_filesize', '16M');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.