i'm using intervention package to upload images with laravel and all things are fine from creating to saving image but the problem in the image column in database it stores this name with path
/private/var/folders/18/0w78rt691m99y_kv8xln4n0c0000gn/T/phpFkP3Gh
this is my code:
if($request->hasFile('image')) {
$image = $request->file('image');
$filename = time() . '.' . $image->getClientOriginalExtension();
$location = public_path('images/' . $filename);
\Image::make($image)->save($location);
}
and this is the image name stored in images file 1503847676.jpg
please help me to find, where is the problem?
this is my whole method
public function update(Request $request, $id)
{
// Validating fields requests
$this->validate($request, [
'title' => 'required|min:6',
'subtitle' => 'required|min:6',
'slug' => 'required',
'body' => 'required',
'image' => 'required|mimes:jpeg,png,jpg,gif,svg'
]);
if($request->hasFile('image')) {
$image = $request->file('image');
$filename = time() . '.' . $image->getClientOriginalExtension();
$location = public_path('images/' . $filename);
\Image::make($image)->save($location);
}
//find target post
$post = Post::find($id);
//create upadeted data from inputs fields
$post->title = $request->title;
$post->subtitle = $request->subtitle;
$post->image = $filename;
$post->slug = $request->slug;
$post->image = $request->image;
$post->status = $request->status;
$post->body = $request->body;
//save the new data to database
$post->save();
$post->tags()->sync($request->tags);
$post->categories()->sync($request->categories);
return redirect('/admin/post');
}
You don't need
Intervention
package for simple image upload w/o any modifications like resize etc. Try this