2

Before I start - I am using Laravel5.

I got the upload image function working, everything is great thanks to you guys, but I started wondering. Is there a proper way of displaying the image before I upload it? I want admin to be able to see the image right after he chooses it, but before the upload, so he will upload the correct image for sure. Just clicking "Browse" -> choosing the image file -> clicks "Open" and then it appears - the preview of the selected image.

I am using a simple laravel5 upload form:

    <form method="POST" action="{!! URL::to('adminPanel/addImg/done/'.$projectId) !!}" accept-charset="UTF-8" enctype="multipart/form-data">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <input name="image" type="file" />
        <br><br>
        <input type="submit" value="Mainīt"/><br>
        {{Session::get('error')}}
    </form> 

SOLVED the solution can be found here right in the first answer: Preview an image before it is uploaded works like a charm, all you need to do is just optimize the code to your situation, there's also a sample of how it works

Community
  • 1
  • 1
Oskars
  • 327
  • 1
  • 17
  • Somewhat OT but if you're using Bootstrap I suggest you have a look at [Jasny Bootstrap](http://jasny.github.io/bootstrap/javascript/#fileinput) - it's an extension that brings in this exact feature (among others). I've used it a few times before and it works great (though I did have to customise the way it works one time as I needed the ability to 'remove picture' as well). – alexrussell May 07 '15 at 12:49
  • @user3158900 yes yes yes yes, thank you, clearly I also searched for the solution before posting the question, but all I found was nothing comapred to that link. I'll edit question. – Oskars May 07 '15 at 13:28

0 Answers0