title: How to upload an Image to server in from android app to Laravel?
body: <p>I am trying to upload an image using Retrofit to Laravel server from Android application. I have used Multipart to upload an image but it shows me <strong>File is empty</strong>.</p>
  <p><strong>Interface to call the api</strong></p>
  <pre><code>@Multipart
  @POST(&quot;jobseeker/update/image&quot;)
  Call&lt;ProfileImageResponse&gt; uploadImage(@Header(&quot;Authorization&quot;) String token,
                                         @Header(&quot;Content-Type&quot;) String contentType,
                                         @Part MultipartBody.Part file);
  </code></pre>
  <p><strong>Method to call the api</strong></p>
  <pre><code>private void uploadImage() {
  
      progressDialog = new ProgressDialog(mContext);
      progressDialog.setMessage(&quot;Processing...&quot;);
      progressDialog.setCancelable(true);
      progressDialog.show();
  
      File file = new File(imagePath);
      Log.v(TAG,&quot;profile image path ::::: &quot; + imagePath);
      if (file.exists()) {
          RequestBody requestFile = RequestBody.create(MediaType.parse(&quot;multipart/form-data&quot;), file);
          // MultipartBody.Part is used to send also the actual file name
          MultipartBody.Part body = MultipartBody.Part.createFormData(&quot;photo&quot;, file.getName(), requestFile);
  
          ApiInterface apiInterface = ApiClient.getApiClient().create(ApiInterface.class);
          Call&lt;ProfileImageResponse&gt; response = apiInterface.uploadImage(getToken(), &quot;multipart/form-data&quot;, body);
          response.enqueue(new Callback&lt;ProfileImageResponse&gt;() {
              @Override
              public void onResponse(Call&lt;ProfileImageResponse&gt; call, Response&lt;ProfileImageResponse&gt; response) {
                  if (response.isSuccessful()) {
                      Log.v(TAG, &quot;image upload response successful!&quot;);
                      //finish();
                      ProfileImageResponse imageResponse = response.body();
                      if (imageResponse != null) {
                          Log.v(TAG, &quot;image uploaded :::: &quot; + imageResponse.success);
                          Log.v(TAG, &quot;image uploaded message:::: &quot; + imageResponse.message);
                          if (imageResponse.message != null) {
                              Toast.makeText(mContext, imageResponse.message, Toast.LENGTH_LONG).show();
                          }
                      }
  
                  } else {
                      Log.v(TAG, &quot;failed&quot;);
                      Toast.makeText(mContext, &quot;ImageUpload  failed!&quot;, Toast.LENGTH_LONG).show();
                  }
  
                  progressDialog.dismiss();
  
              }
  
              @Override
              public void onFailure(Call&lt;ProfileImageResponse&gt; call, Throwable t) {
                  progressDialog.dismiss();
                  t.printStackTrace();
                  Log.e(TAG, &quot;exception : &quot; + t.getMessage());
                  //Log.e(TAG, t.getMessage());
              }
          });
      }else {
          Log.e(TAG,&quot;File does not exists&quot;);
      }
  }
  </code></pre>
  <p><strong>Log message</strong>
  <a href="https://i.stack.imgur.com/vF4Dz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vF4Dz.png" alt="enter image description here" /></a></p>
  <p><strong>Backend method</strong></p>
  <pre><code>public function updateImg(Request $request)
    {
      if ($request-&gt;hasFile('photo')) {
        $validation = $this-&gt;validate($request, [
          'photo' =&gt; 'image|mimes:jpeg,png,jpg,svg|max:5120',
        ]);
        $filename = fileUpload($request-&gt;file('photo'), 'storage/images/profile-image/');
        $request-&gt;merge([
          'image' =&gt; $filename,
        ]);
        $row = $this-&gt;personalInfo-&gt;getByUserId(auth()-&gt;id());
        $row-&gt;update($request-&gt;all());
        return response()-&gt;json([
          'success' =&gt; true,
          'message' =&gt; 'Profile image updated successfully'
        ]);
      }else{
        return response()-&gt;json([
          'error' =&gt; true,
          'message' =&gt; 'Please select the photo'
        ]);
      }
    }
  </code></pre>
  <p>In my code its I am converting imagePath to File and them File to Multipart and then sending to the server but Server response is <strong>Please select the photo</strong>.
  Can anyone please help me to resolve this issue?</p>
  <p>If you need more information please add a comment.</p>