adhik13th's avatar

Cannot Upload image in larvel-6, Show The “E:\xampp\tmp\php3A05.tmp” file does not exist or is not readable

i have a Module upload file . and its working normally at laravel 5.8 . ut i update this laravel to 6.2 version its having error like this :

The "C:\xampp\tmp\phpC108.tmp" file does not exist or is not readable.

this is my upload store function

public function store_cuti(Request $request)
{
   
    $this->validate($request,[
        
    ] );

    if($request->hasfile('berkas'))

    {   
    $file = $request->file('berkas');
        $extension = $request->berkas->getClientOriginalExtension();  //Get Image Extension
        $fileName =  uniqid().'.'.$extension;  //Concatenate both to get FileName (eg: file.jpg)
        $file->move(public_path().'/file_cuti/', $fileName);  
        $data = $fileName;  
    }


    $users = new Data_cuti;
    $users->user_id              = $request->user_id ;
    $users->nama_surat           = $request->nama_surat ;
    $users->tgl_surat            = $request->tgl_surat ;
    $users->durasi_cuti          = $request->durasi_cuti ;
    $users->tgl_mulai            = $request->tgl_mulai ;
    $users->status               = $request->status ;
    $users->berkas               = $data;
    $cuti = DB::table('users')->select('users.cuti')->where('id',$request->user_id)->first();
        if(Input::get('durasi_cuti') > $cuti){
            return redirect()->back();
        }
        elseif($cuti > Input::get('durasi_cuti')){
            DB::table('users')->where('id', $request->user_id)->decrement('cuti' , Input::get('durasi_cuti'));
        }
        else{
            return ('error , tidak ada input');
            return redirect()->back();
        }
   
    dd($data);
    // $users->save();
    // return redirect ('cuti_pegawai')->with('success', 'Input Succes');
    

}

someone have a solution for this problem ?

#UPDATE.... i know this problem . this problem is from line

$cuti = DB::table('users')->select('users.cuti')->where('id',$request->user_id)->first();
        if(Input::get('durasi_cuti') > $cuti){
            return redirect()->back();
        }
        elseif($cuti > Input::get('durasi_cuti')){
            DB::table('users')->where('id', $request->user_id)->decrement('cuti' , Input::get('durasi_cuti'));
        }
        else{
            return ('error , tidak ada input');
            return redirect()->back();
        }

if i delete this line its work normally . but i need this line to update some data in another field table

0 likes
21 replies
adhik13th's avatar

sir , i update my question , i always add this

enctype="multipart/form-data"

on my input form

adhik13th's avatar

i think i dont have problem on my upload file . its be cleared , but , in my store function i have function to update another table . i have 2 table users and cuti . i store to cuti and update 1 colomn in table users its on here

$cuti = DB::table('users')->select('users.cuti')->where('id',$request->user_id)->first();
    if(Input::get('durasi_cuti') > $cuti){
        return redirect()->back();
    }
    elseif($cuti > Input::get('durasi_cuti')){
        DB::table('users')->where('id', $request->user_id)->decrement('cuti' , Input::get('durasi_cuti'));
    }
    else{
        return ('error , tidak ada input');
        return redirect()->back();
    }
jlrdw's avatar

Is Input::get still working in version 6, you may need to change that.

adhik13th's avatar

I changed this and still didnt solve . I dont know what happen

jlrdw's avatar

Clear all cache and those temporary view files.

Also open the browser developer tools and start seeing what's going on.

If you change that request it should work especially if it was working in the previous version.

anandnaga's avatar

i have same problem but i try this--> check your table columns .. some columns get not nullable value. put null value .

adhik13th's avatar

you mean i need all colomn need to use nullable ?

jlrdw's avatar

Check your storage folder permissions also. I don't understand if it was working at 5.8 and you upgraded to 6, and changed the facade usage, it should work.

I know in a fresh install of 6 I have no problems uploading files.

adhik13th's avatar

me too , i dont know what happen , i never see this error like this before use laravel under 6 .

jlrdw's avatar

Try a fresh new install of laravel 6. I've had no trouble uploading any files.

jlrdw's avatar

Also example I gave a while back

// validate as needed
<form action='add' method='post' enctype="multipart/form-data">
        <table style="border:none; width: 700px;">
            <tr>
                <td>dogpic:</td>
                <td>
                    <input name="ufile" type="file" id="ufile" size="50" /></td>
                </td>
            </tr>
             ///////////// more code for form

controller

           $lid = DB::table('dc_dogs')->count();
            $lid = $lid + 1;
            $file = Request::file('ufile');
            $file_name = $file->getClientOriginalName();
            $file_ext = $file->getClientOriginalExtension();

            $fileInfo = pathinfo($file_name);
            $filename = $fileInfo['filename'];
            $newname = $filename . $lid . "." . $file_ext;
            $destinationPath = ASSET . 'upload/imgdogs'; // use your path here not mine.
            $file->move($destinationPath, $newname);

            $dogpic = $newname;
           
            $dogname = ucfirst(Request::input('dogname'));
            $sex = ucfirst(Request::input('sex'));
            $comments = Request::input('comments');
            $adopted = !empty(Request::input('adopted')) ? '1' : '0';
            $lastedit = date("Y-m-d H:i:s");

            $postdata = array(
                'dogpic' => $dogpic,
                'dogname' => $dogname,
                'sex' => $sex,
                'comments' => $comments,
                'adopted' => $adopted,
                'lastedit' => $lastedit
            );

            DB::table('dc_dogs')->insert($postdata);
           
bhavin-zwt's avatar

@adhik13th I have just read your first message. I have one query regarding your question. Which line will be removed then this error is solved?

indraranuh's avatar

i have same problem here, i added enctype="multipart/form-data" on my form and didn't work. then i've tried to dump my input and boom, there is no file on my input and the output is "D:\xampp\tmp\php7F01.tmp". and i still cant move the file to my destination folder

Please or to participate in this conversation.