我使用的是laravel 5.2 php5.6 fpm。我有表格,我可以上传视频文件。如果我上传小视频,上传文件并显示其余输入,一切正常,但如果我尝试上传更大的视频(例如4MB),则WHOLE输入为空,它只返回null
。所以没有提供任何输入。
我的php.ini
upload_max_filesize = 200M
post_max_size = 200M
memory_limit = 800M # increased it, just to make sure its not causing the problem
我重申了服务器,nginx,php-fpm进程,清除了缓存,但它是一样的。
我用js FormData
$("input.uploaded_photos,input.uploaded_videos").change(function(){
var input = this;
var albumId = $("[name='id']").val();
var albumType = $("[name='type']:checked").val();
//only continue if currently selected album type matches the current input field
if($(input).attr('data-type') == albumType){
if (input.files && input.files.length) {
var selectedType = $(input).parents('form').find("[name='type']:checked").val();
var existingUploads = $('.selling-album-upload-' + selectedType + 's-row .selling-album-upload').length;
var totalResultingUploads = input.files.length + existingUploads;
var selectedPackCount = parseInt($(input).parents('form').find("[name='picture_pack']").val());
var dataform = new FormData();
for(var iFile in input.files){
if(!isNaN(iFile)){//otherwise we'll get 'length' and 'file' as keys too
var file = input.files[iFile];
dataform.append(input.name, file, file.name);
}
}
dataform.append('album_id', albumId);
dataform.append('type', albumType);
$.ajax({
url: '/myurl'
type: 'POST',
data: dataform,
async: false,//false, otherwise it creates a GET Request
success: function (data) {
// do something
},
cache: false,
contentType: false,
processData: false
});
}
}
});
如果我上传' large'视频Input::all()
返回null,它的空白,我认为问题应该在js中。无论如何这里的PHP代码:
public function postAddSellingAlbumUpload(){
$album_id = Input::get('album_id');
$type = Input::get('type');
$existing_uploads = Session::get('agent_selling_uploaded_$type'.'s', []);
$new_uploads = [];
$posted_files = Input::file('uploaded_'.$type.'s');
foreach($posted_files as $posted_file){
$path = '/uploads/tmp/'.uniqid().'.'.Userimage::guessExtension($posted_file->path());
File::copy($posted_file->path(), public_path().$path);
$posted_file_id = uniqid();
$new_uploads[$posted_file_id] = [
'id' => $posted_file_id,
'album_id' => $album_id,
'type' => $type,
'path' => $path,
];
}
Session::put('agent_selling_uploaded_$type'.'s', array_merge($existing_uploads, $new_uploads));
return response()->json([
'success' => true,
'uploads' => $new_uploads,
]);
}
再一次,问题发生在上传' large'文件。如果文件很小,一切都还可以。似乎问题是关于upload_max_filesize
,但我正确设置了配置文件
答案 0 :(得分:1)
最后发现,我的操作系统上有多个php版本,其中一个(正在运行)有upload_max_filesize = 2M
和post_max_size = 8M
导致问题