title: Laravel saving image in storage
body: <p>my code was working fine but now it is not, as image is not saving in folder, i am trying to save image in storage folder, with id as image name.</p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>  if($request-&gt;hasFile('profile_pic')){
          if (Input::file('profile_pic')-&gt;isValid()) {
              $file = Input::file('profile_pic');
              $destination = 'storage/app/teachers'.'/';
              $ext= $file-&gt;getClientOriginalExtension();
              $mainFilename = $teacher-&gt;id.request()-&gt;$ext;
              $file-&gt;move($destination, $mainFilename.".".'jpg');
              echo "uploaded successfully";
          }
  </code></pre>
  
  <p><strong>View:</strong> where 0000 is default image.</p>
  
  <pre><code>&lt;div class="row"&gt;
   &lt;a href="#"&gt;  &lt;img id="imgFileUpload" name="profile_pic" src={{asset('storage/app/teachers/'.'0000'.'.jpg')}} value="{{@$teacher-&gt;id}}"
     onerror="this.src='storage/app/teachers/0000.jpg';" data-toggle="tooltip" data-placement="top" title="click to upload image" class="profile_pic rspimg shadow-sm bg-white rounded" id="imgFileUpload"   data-toggle="tooltip" data-placement="top" title="Click To Upload image"&gt;&lt;/a&gt;
       &lt;div class=" col-md-10"&gt;
       &lt;input type="file"  name="profile_pic" id="FileUpload1" style="display: none" /&gt;
       &lt;span id="spnFilePath"&gt;&lt;/span&gt;
       &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>ajax:</strong> to preview image in browser.</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function(){
  $(function () {
   alert(2);
      $("#FileUpload1").change(function () {
                  var imgControlName = "#imgFileUpload";
                  readURL(this, imgControlName);
          });
  function readURL(input, imgControlName) {
                  if (input.files &amp;&amp; input.files[0]) {
                          var reader = new FileReader();
                          reader.onload = function (e) {
                                  $(imgControlName).attr('src', e.target.result);
                          }
                          reader.readAsDataURL(input.files[0]);
                  }
          }
          var fileupload = $("#FileUpload1");
          var image = $("#imgFileUpload");
          image.click(function () {
                  fileupload.click();
          });
  
  });
      });
  &lt;/script&gt;
  </code></pre>