title: How to upload image from VueJS to Symfony with Axios?
body: <p>I have the VueJS component installed without problem in my project with Symfony 4 but at the moment I want to upload an image. I follow this reference from Laravel: <a href="https://es.stackoverflow.com/questions/157285/c%C3%B3mo-subir-imagen-desde-vuejs-a-laravel-con-axios">How to upload image from VueJS to Laravel with Axios</a>?</p>
  
  <p>I get to the controller but that's where the value in base 64 does not reach just the console message.</p>
  
  <p>Code:</p>
  
  <pre><code>//CargaFoto.vue
  &lt;template&gt;
      &lt;div class="hello"&gt;
          &lt;h1&gt;{{ msg }}&lt;/h1&gt;
          &lt;input type="file" name="image" @change="getImage" accept="image/*"&gt;
          &lt;button @click="updateAvatar"&gt;Subir Imagen&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
      import axios from 'axios'
  
      export default {
          name: "CargaFoto",
          data() {
              return {
                  msg: "Cargar Imagen de Perfil",
                  imagen: null
             };
          },
          methods: {
              getImage(event){
              //Asignamos la imagen a  nuestra data
              this.imagen = event.target.files[0];
          },
          updateAvatar(){
              //Creamos el formData
              var data = new  FormData();
              data.append('avatar', this.imagen);
              data.append('_method', 'POST');
              //Enviamos la petición
              axios.post('/usuario/jsonimagen',data)
                  .then(response =&gt; {
                      console.log(res)
                  })
          }
  &lt;/script&gt;
  </code></pre>
  
  <p>And this the controller code:</p>
  
  <pre><code>/**
   * @return JsonResponse
   * @Route("/jsonimagen", name="jsonimagen", methods="POST")
   */
  public function jsonimagen(Request $request):JsonResponse
  {
  
      $data= $request-&gt;get("data");
      return $this-&gt;json($data);
  }
  </code></pre>
  
  <p>The answer is <code>null</code> The doubt that I have is how I upload the image to the local server.</p>