adhik13th
183
15
Laravel

Laravel saved file to wrong directory

Posted 6 days ago by adhik13th

I have a function to upload file . on Localhost its not having error . but after i deploy on shared hosting , its have problem . if localhost ,im not moving some folder , but on "tutorial" shared hosting , i need making 2 folder . laravel and public . this laravel folder is all file on project laravel without public

its my schema on my shared hosting

(/home/sippausr)

etc

laravel ->

  • app

  • bootstrap

  • config

  • database

  • public_html

    • files ( this file saved here)
  • resources

  • routes

  • storage

  • tests

  • vendor

logs

mail

public_ftp

public_html ->

  • css

  • files (not on here, i need to save here)

  • home

  • images

  • js

  • kalibrasi

  • public

  • sop

  • theme

and i have a function to upload file and saved this file to directory files on public_html like this

public function store6(Request $request)
{
    $this->validate($request, [
        

    ]);

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

        
        {   $file = $request->file('image');
            $name=$file->getClientOriginalName();
            $file->move(public_path().'/files/', $name);  
            $data = $name;  
        }
    

    $user = new pemeliharaan;
    $id = Auth::user()->id;

    $user->user_id = $id;
    $user->alat_id = $request->alat_id;
    $user->pertanyaan =json_encode($request->except
    (['_token','name','alat_id','status','catatan','image']));
    $user->catatan = $request->catatan;
    $user->image=$data;
    $user->status = $request->status;


    $user->save();
  // dd($user);
    return redirect('user/show6')->with('success', 'Data Telah Terinput');

}

but , this file not saved at public_html/files ,

this file saved at Laravel folder , on public_html( you can see at schema) . can someone help me ?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.