0

I want to upload image in laravel-6.2, But show The "E:\xampp\tmp\php3A05.tmp" file does not exist or is not readable. My controller function:

 $data = new Vedio();

        if($request->hasFile('image')){
            $files = $request->file('image');
            $extension = $files->getClientOriginalExtension();
            $fileName = str_random(5) . "-" . date('his') . "-" . str_random(3) . "." . $extension;
            $folderpath = 'public/'.'Vedio/' . date('Y') . '/';
            $image_url = $folderpath . $fileName;
            $files->move($folderpath, $fileName);
            // $data['topheadline_image'] = $image_url;
            $data->image = $image_url;
        }

        $data->link=$request->link;
        $data->title=$request->title;



        $data->status=0;
        $data->save();
        return redirect('/admin-dashbord/Vedio-list')->with('success','Data saved in database successfully');


      }

This is my view file code: This is my view file code: This is my view file code: This is my view file code: This is my view file code:

<form class="form-horizontal"action="{{url('/admin-dashbord/Vedio-post')}}" method="POST"enctype="multipart/form-data">
                @csrf
                    <fieldset>
                      <div class="control-group">
                        <label class="control-label" for="focusedInput">Title</label>
                        <div class="controls">
                          <input class="input-xlarge " id="" name="title"type="text" value="">

                        </div>
                      </div>

                      <div class="control-group">
                          <label class="control-label" for="focusedInput">Link</label>
                          <div class="controls">
                            <input class="input-xlarge " id="" name="link"type="text" value="">

                          </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="focusedInput">Image</label>
                            <div class="controls">
                              <input class="input-xlarge " id="" name="image"type="file" value="">

                            </div>
                          </div>




                      <div class="form-actions">
                        <button type="submit" class="btn btn-primary">Save changes</button>
                        <button class="btn">Cancel</button>
                      </div>
                    </fieldset>
                  </form>
Malkhazi Dartsmelidze
  • 4,783
  • 4
  • 16
  • 40
Monsur Ahmed
  • 23
  • 2
  • 10

2 Answers2

0

Try to replace

$folderpath = 'public/'.'Vedio/' . date('Y') . '/';

to

$folderpath = public_path().'/Vedio/'. date('Y'). $fileName;
$files->move($folderpath);
$data->image = $folderpath;

Also, I don't know why you save the whole $folderpath in database, you can save the name of image only then you could do something like

$image = public_path().'/Vedio/'.$data->image;
Eyad Jaabo
  • 391
  • 3
  • 13
0

If your version of Larval 6 is not working then you need to install Larval 6.2. Check your composer.json once.

Tabish
  • 161
  • 3
  • 17