0

whene uploads image on laravel 6 show this Error

SplFileInfo::getSize(): stat failed for C:\xampp\tmp\php88C2.tmp

my Code

public function store(Request $request) {

        $this->validate($request,[
            "title"    => "required",
            "content"  => "required",
            "category_id"  => "required",
            "post_image" => "required|image",

        ]);

        $post_image = $request->post_image;
        $featured_new_name = time().$post_image->getClientOriginalName();
        $post_image->move('uploads/posts',$featured_new_name);

        $post = Post::create([
            "title"    => $request->title,
            "content"  => $request->content,
            "category_id"  => $request->category_id,
            "post_image" => 'uploads/posts/'.$featured_new_name,

        ]);


     return redirect()->back();
}
Hesham Adel
  • 1
  • 1
  • 2
  • Possible duplicate of [RuntimeException SplFileInfo::getSize(): stat failed for... Laravel 4 upload image](https://stackoverflow.com/questions/24138189/runtimeexception-splfileinfogetsize-stat-failed-for-laravel-4-upload-ima) – cOle2 Sep 19 '19 at 17:24

3 Answers3

0

I think error is not because of uploading.it might be at insertion to database.try to check the column names of table with those keys you used in code

ashik
  • 1
  • 2
0

You configure wrong filename

 $post_image = $request->file('post_image');
 $featured_new_name = time().".".$post_image->getClientOriginalName();
 //File name will be like this '2568412.jpg/png/other'
Ripon Uddin
  • 709
  • 3
  • 14
  • 29
0

I encountered this problem recently and actually found that it was a problem of insertion in database. I had updated the database and added the image column but didn't have the database migrated. Migrating fixed it for me. Give it a check once.

Ronish
  • 181
  • 1
  • 3