无法在laravel中上传大于2MB的文件

时间:2018-08-14 04:44:02

标签: php laravel

当前,我正在laravel中进行CMS,并且尝试将文件上传到laravel中超过2MB,并且它显示该图像无法上传。

我的控制器代码。

    $this->validate($request ,[
        'title' => 'required',
        'featured' => 'required|image',
        'content' => 'required',
        'category_id' => 'required',
        'tags' => 'required'
    ]);

    $featured = $request->featured;

    $featured_new_name = $featured->getClientOriginalName();

    $featured->move('uploads/posts', $featured_new_name);

    $post = Post::create([
        'title' => $request->title,
        'slug' => str_replace(' ', '-', $request->title),
        'featured' => 'uploads/posts/' . $featured_new_name,
        'content' => $request->content,
        'category_id' => $request->category_id,
        'user_id' => Auth::id()

    ]);   

     $post->tags()->attach($request->tags);

    Session::flash('success', 'Post Created Sucessfully.');

    return redirect()->route('posts');

3 个答案:

答案 0 :(得分:3)

例如,尝试增加php.ini中的以下值:

memory_limit = 32M
upload_max_filesize = 24M
post_max_size = 32M

或选中此link

答案 1 :(得分:3)

增加php.ini中的内存限制是最好的主意。 如果您只是想增加此函数的内存限制,请在函数上使用此代码。

OCI-Lob::write(): ORA-01031: insufficient privileges  

答案 2 :(得分:1)

echo phpinfo();

enter image description here

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Maximum allowed size for uploaded files
upload_max_filesize = 4M