skip to Main Content

how to upload image to src/assets folder in vuejs because now i want to upload it to my desired folder to test before i can use real server.
Please help me to solve this problem.
I want to upload version to folder and upload to api server.

                  <label
                class="imagePreviewWrapper"
                style="cursor: pointer"
                for="file"
              >
                <div class="imageContainer">
                  <input
                    ref="fileInput"
                    type="file"
                    id="file"
                    @change="uploadFile"
                    style="display: none"
                    accept=".jpg"
                  />
                  <img :src="previewImageUrl" alt="Preview Image" />
                  <i class="bi bi-camera icon"></i>
                </div>
              </label>

2

Answers


  1. You can’t. the thing about SPA is that your code runs on the browser. So you need server to do something like that.

    The solution is just send your file to your server and let them handle the upload

    Login or Signup to reply.
  2. As I know you cannot upload something dynamically for src/assets folder. because it uses to save assets for development. you have to create some folder or if you using firebase like service then you want to add firebase storage like service as well. because src/assets folder is rendering when building the vue application. so after building vue app there are no more src/assets folder.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search