You're going to need to move those images from the tmp/ folder and rename them - if you're on 5.3 take a look at this screencast. I prefer being explicit about what I'm saving to the database rather than just doing $request->all(). You could always extract the post creation logic into a protected method or class if you want to clean up your controller.
Best way to upload image in "blog" app
Hi everyone.
My problem is quite complicated (for me). I'm making some kind of blog app. My Posts table/model have quite a lot of fields to fill up during the proces of creation. So. I want to have as clean controllers as possible. For now I have been using something like this:
public function store(PostRequest $request)
{
$post = Post::create($request->all());
// Some response and redirect
}
But there is an issue with that code. With text content it works fine but I've got to upload 2 images too. Now, when I submit the form with these images they show up in database as paths to tmp/ folder (placed by PHP file upload function). Am I supposed to fill up all the fields "manually"? I mean:
$post = new Post();
$post->filed1 = $request->input('field1');
$post->filed2 = $request->input('field2');
// etc... about 12 :( It looks so messy, ugh!
Maybe there is a better way to do this. I also consider how to stucture my galleries/photo uploads. Maybe someone can suggest me anything ("The right way")?
Please or to participate in this conversation.