问题已修复。谢谢
当上传超过2mb的文件时,mineType会更改,并且文件不会发送到服务器
当上传文件<2mb是好的 但当文件超过2mb(例如7mb(时,不上传
Sever Apache
is文件>2mb(不上传(
'test' => false,
'originalName' => 'IMG_1241.JPG',
'mimeType' => 'application/octet-stream',
是文件<2mb(上传成功(
'originalName' => '129730813_1484434941749595_546569280234563733_n.jpg',
'mimeType' => 'image/jpeg',
当上传更多2mb时更改mineType
memory_limit = 32M
upload_max_filesize = 24M
post_max_size = 32M
这是我的代码
UIkit.upload('.js-upload', {
url: this.required_api.dataset.uploadProcess,
multiple: true,
allow : '*.(jpg|jpeg|gif|png)',
name: 'files[]',
type: 'text',...
foreach ($request->file('files') as $file) {
$item = $file->getClientOriginalName();
$item_name = preg_replace('/\.[^.\s]{3,4}$/', '', $item);
$item_ext = $file->extension();
$filename = Str::slug($item_name);
$count = MediaModel::where('file_without_ext', 'LIKE', "{$filename}%")->count();
if($count > 0) {
$filename = $filename . '-'. ++$count;
}
/** only admin */
$admin_dir = public_path('/wp-upload/admin');
$img_size_small = Image::make($file->path());
$img_size_small->resize(150, 150, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->save($admin_dir.'/'.$filename.'-150x150.'.$item_ext, 100);
}
如果您使用nginx
您必须增加client_max_body_size。它的默认值是每个文件1 MB。
在nginx项目的default.conf中添加以下内容:
server {
...
client_max_body_size 32M;
...
}