Reputation: 463
It is working good for full path like this
$file=$request->file('file');
$file->move('C:\xampp\htdocs\modo\images',$file->getClientOriginalName());
But i cant understand why it doesnt for root folder path :
$file->move('\modo\images',$file->getClientOriginalName());
Upvotes: 11
Views: 61998
Reputation: 3192
You need to use base_path()
method. This method returns the fully qualified path to the project root:
So in your case try the below code:
$file = $request->file('file');
$file->move(base_path('\modo\images'), $file->getClientOriginalName());
and if you want to return the public directory then use:
$path = public_path();
For more info read Laravel helper functions
Upvotes: 26
Reputation: 4026
You need to do it this way:
$file->move(base_path('\modo\images'),$file->getClientOriginalName());
Upvotes: 2