The laravel text form and the Image Upload form are submitted together. How does the Controller handle this?

Source: Internet
Author: User
The following is an example in the Controller. Its images are dispensable, so they are separated separately for processing. Now, if you want to change it, the image must be uploaded. Can you combine the image with the text $ request-& amp; gt; all? How to modify the code? The following is the view under {code:

The following is an example in the Controller. Its images are dispensable, so they are separated separately for processing. Now, if you want to change it, that is, the image must be uploaded. Can you combine the image with the text $ request-> all? How to modify the code?

public function store(ArticleRequest $request){    $article = new Article($request->except('image'));    $article -> user_id = Auth::id();    $picture = "";    if(Input::hasFile('image'))    {        $file = Input::file('image');        $filename = $file->getClientOriginalName();        $extension = $file -> getClientOriginalExtension();        $picture = sha1($filename . time()) . '.' . $extension;    }    $article -> picture = $picture;    $article -> save();    if(Input::hasFile('image'))    {        $destinationPath = public_path() . '/images/article/'.$article->id.'/';        Input::file('image')->move($destinationPath, $picture);    }}

The following is the view:

Reply content:

The following is an example in the Controller. Its images are dispensable, so they are separated separately for processing. Now, if you want to change it, that is, the image must be uploaded. Can you combine the image with the text $ request-> all? How to modify the code?

public function store(ArticleRequest $request){    $article = new Article($request->except('image'));    $article -> user_id = Auth::id();    $picture = "";    if(Input::hasFile('image'))    {        $file = Input::file('image');        $filename = $file->getClientOriginalName();        $extension = $file -> getClientOriginalExtension();        $picture = sha1($filename . time()) . '.' . $extension;    }    $article -> picture = $picture;    $article -> save();    if(Input::hasFile('image'))    {        $destinationPath = public_path() . '/images/article/'.$article->id.'/';        Input::file('image')->move($destinationPath, $picture);    }}

The following is the view:

Can I perform asynchronous upload?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.