title: How to upload image to server using php laravel?
body: <p>I've  been trying to write an api to upload image to server ,but all in vain.
  I'm using the laravel framework .And tried <a href="https://itsolutionstuff.com/post/laravel-5-fileimage-upload-example-with-validationexample.html" rel="nofollow noreferrer">this example</a> but it is not working.</p>
  
  <p>Also while testing the api from POSTMAN ,I have passed mutlipart/form-data in the Headers.And in the Body tab selected form-data, added key = image, changed it Text to File and added an image.But when I test the api , don't know why but the image request is empty.</p>
  
  <p>Maybe I might be passing something wrong in POSTMAN or there might be something wrong in my code,please do help me.</p>
  
  <p>Here's my api code</p>
  
  <pre><code>public function upload(Request $request){
  
  if ($request-&gt;hasFile('image')) {
     $image = $request-&gt;file('image');
     $name = md5(time().uniqid()).".png";
     $destinationPath = base_path() . '/public/uploads/images/' . $name;
  
     move_uploaded_file($name, $destinationPath);
  
     return response()-&gt;json(['title'=&gt;"image is uploaded"]);
     }
  
  }
  </code></pre>
  
  <p>And my controller code :</p>
  
  <pre><code>Route::post('uploadImage','TestController@upload');
  </code></pre>
  
  <p>Screenshot of the postman request.Please tell me if I'm passing something wrong in header or body .</p>
  
  <p><a href="https://i.stack.imgur.com/8YxWY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8YxWY.png" alt="enter image description here"></a></p>
  
  <p>Also ,the console shows this error <code>Missing boundary in multipart/form-data POST data in Unknown on line 0</code></p>