{"id":28249,"date":"2021-06-02T08:55:02","date_gmt":"2021-06-02T08:55:02","guid":{"rendered":"http:\/\/How-to-Upload-Images-in-Vue.js-with-Drag-N-Drop"},"modified":"2025-02-08T17:07:30","modified_gmt":"2025-02-09T01:07:30","slug":"how-to-upload-images-in-vue-js-with-drag-n-drop","status":"publish","type":"post","link":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/","title":{"rendered":"How to Upload Images in Vue.js with Drag N Drop"},"content":{"rendered":"<div class=\"wp-block-cloudinary-markdown \"><h2>Introduction<\/h2>\n<p>According to the Stack Overflow 2020 survey, <a href=\"vuejs.org\/\">Vue.js<\/a> was one of the developer\u2019s <a href=\"https:\/\/insights.stackoverflow.com\/survey\/2020#most-popular-technologies\">Most Loved Web frameworks<\/a>. In this media jam, we will see how to upload an image to Cloudinary in Vue.js with a drag and drop operation.<\/p>\n<p>If you want to jump right into the code, check out the <a href=\"https:\/\/github.com\/lelouchB\/vue-image-upload\">GitHub Repo here<\/a>.<\/p>\n<h2>CodeSandbox<\/h2>\n<\/div>\n  \n  <div class=\"wp-block-cloudinary-code-sandbox \">\n    <iframe\n      src=\"https:\/\/codesandbox.io\/embed\/vue-image-upload-0vfg6?theme=dark&amp;codemirror=1&amp;highlights=&amp;editorsize=50&amp;fontsize=14&amp;expanddevtools=0&amp;hidedevtools=0&amp;eslint=0&amp;forcerefresh=0&amp;hidenavigation=0&amp;initialpath=%2F&amp;module=%2Fsrc%2FApp.vue&amp;moduleview=0&amp;previewwindow=&amp;view=&amp;runonclick=1\"\n      height=\"500\"\n      style=\"width: 100%;\"\n      title=\"vue-image-upload\"\n      loading=\"lazy\"\n      allow=\"accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking\"\n      sandbox=\"allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts\"\n    ><\/iframe>\n  <\/div>\n\n  <div class=\"wp-block-cloudinary-markdown \"><h2>Setup<\/h2>\n<p>In this tutorial, you will use <a href=\"https:\/\/cli.vuejs.org\/\">Vue CLI<\/a> to create the initial Vue.js project. Run the following command to install the Vue CLI.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\"><span class=\"hljs-selector-tag\">npm<\/span> <span class=\"hljs-selector-tag\">install<\/span> <span class=\"hljs-selector-tag\">-g<\/span> <span class=\"hljs-keyword\">@vue<\/span>\/cli\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Now, create a Vue.js project named <code>vue-image-upload<\/code> by running the following command in the terminal.<\/p>\n<pre class=\"js-syntax-highlighted\"><span><code class=\"hljs shcb-wrap-lines\">vue create vue-image-upload\n<\/code><\/span><\/pre>\n<p>When prompted to choose the preset, the <code>Default (Vue 3) ([Vue 3] babel, eslint)<\/code> preset.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\"><span class=\"hljs-selector-tag\">Vue<\/span> <span class=\"hljs-selector-tag\">CLI<\/span> <span class=\"hljs-selector-tag\">v4<\/span><span class=\"hljs-selector-class\">.5<\/span><span class=\"hljs-selector-class\">.13<\/span>\n? <span class=\"hljs-selector-tag\">Please<\/span> <span class=\"hljs-selector-tag\">pick<\/span> <span class=\"hljs-selector-tag\">a<\/span> <span class=\"hljs-selector-tag\">preset<\/span>:\n  <span class=\"hljs-selector-tag\">Default<\/span> (<span class=\"hljs-selector-attr\">&#91;Vue 2]<\/span> <span class=\"hljs-selector-tag\">babel<\/span>, <span class=\"hljs-selector-tag\">eslint<\/span>)\n&gt; <span class=\"hljs-selector-tag\">Default<\/span> (<span class=\"hljs-selector-tag\">Vue<\/span> 3) (<span class=\"hljs-selector-attr\">&#91;Vue 3]<\/span> <span class=\"hljs-selector-tag\">babel<\/span>, <span class=\"hljs-selector-tag\">eslint<\/span>)\n  <span class=\"hljs-selector-tag\">Manually<\/span> <span class=\"hljs-selector-tag\">select<\/span> <span class=\"hljs-selector-tag\">features<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>After the project has been created, run the following command to start the development server.<\/p>\n<pre class=\"js-syntax-highlighted\"><span><code class=\"hljs shcb-wrap-lines\">cd vue-image-upload\nnpm run serve\n<\/code><\/span><\/pre>\n<p>Navigate to <a href=\"http:\/\/localhost:8080\/\">http:\/\/localhost:8080\/<\/a> in your browser, here is how your app will look like.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1622376380\/e-603fc45fe6c0b4006873802f\/pt3thy9kv5ojnucsoy9m.png\" alt=\"Vue.js Initial App\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1920\" height=\"908\"\/><\/p>\n<p>Update the <code>src\/App.vue<\/code> file to clean the sample code like this.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">template<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1<\/span>&gt;<\/span>Vue Image Upload<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h1<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">template<\/span>&gt;<\/span>\n\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span>&gt;<\/span><span class=\"javascript\">\n<span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">default<\/span> {\n  <span class=\"hljs-attr\">name<\/span>: <span class=\"hljs-string\">\"App\"<\/span>,\n  <span class=\"hljs-attr\">components<\/span>: {},\n};\n<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\n\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">style<\/span>&gt;<\/span><span class=\"css\">\n<span class=\"hljs-selector-id\">#app<\/span> {\n  <span class=\"hljs-attribute\">font-family<\/span>: Avenir, Helvetica, Arial, sans-serif;\n  <span class=\"hljs-attribute\">-webkit-font-smoothing<\/span>: antialiased;\n  <span class=\"hljs-attribute\">-moz-osx-font-smoothing<\/span>: grayscale;\n  <span class=\"hljs-attribute\">text-align<\/span>: center;\n  <span class=\"hljs-attribute\">color<\/span>: <span class=\"hljs-number\">#2c3e50<\/span>;\n  <span class=\"hljs-attribute\">margin-top<\/span>: <span class=\"hljs-number\">60px<\/span>;\n}\n<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">style<\/span>&gt;<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Here is how your app will look like now.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1622376801\/e-603fc45fe6c0b4006873802f\/e5slmu54plrpopepztfk.png\" alt=\"Cleaned Sample Code\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1920\" height=\"340\"\/><\/p>\n<p>In this tutorial, you will upload the image with a POST request to the Cloudinary REST API. For this, you will need to create an <a href=\"https:\/\/cloudinary.com\/documentation\/upload_images#unsigned_upload\">unsigned preset<\/a> to upload without any authentication signature.<\/p>\n<p>Head over to <strong>Settings \u2192 Upload \u2192 Upload presets<\/strong> on your Cloudinary dashboard and create an unsigned preset if one doesn\u2019t already exist and copy it.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1622376484\/e-603fc45fe6c0b4006873802f\/sozt8yhmxedmeyxvk776.png\" alt=\"Cloudinary Settings\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1224\" height=\"686\"\/><\/p>\n<p>Create a file named <code>.env<\/code> by running the following command to store your Cloudinary cloud name and Upload Preset securely.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css shcb-wrap-lines\"><span class=\"hljs-selector-tag\">touch<\/span> <span class=\"hljs-selector-class\">.env<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Paste the cloud name and upload preset to the <code>.env<\/code> file.<\/p>\n<pre class=\"js-syntax-highlighted\"><code>VUE_APP_CLOUD_NAME =&quot;&quot;\nVUE_APP_UPLOAD_PRESET = &quot;&quot;\n<\/code><\/pre>\n<h2>How To Drag N Drop Images in Vue.js<\/h2>\n<p>In this section, you will build the dropzone for dragging and dropping the images. You will use <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTML_Drag_and_Drop_API\">HTML5 Drag and Drop API<\/a> to make this dropzone.<\/p>\n<p>Update <code>App.vue<\/code> file like this.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">template<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1<\/span>&gt;<\/span>Vue Image Upload<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h1<\/span>&gt;<\/span>\n\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">div<\/span>\n    <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"dropzone\"<\/span>\n    @<span class=\"hljs-attr\">dragover.prevent<\/span>\n    @<span class=\"hljs-attr\">dragenter.prevent<\/span>\n    @<span class=\"hljs-attr\">dragstart.prevent<\/span>\n    @<span class=\"hljs-attr\">drop.prevent<\/span>=<span class=\"hljs-string\">\"handleFileChange($event.dataTransfer)\"<\/span>\n  &gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">input<\/span>\n      <span class=\"hljs-attr\">id<\/span>=<span class=\"hljs-string\">\"file-input\"<\/span>\n      <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"file\"<\/span>\n      <span class=\"hljs-attr\">accept<\/span>=<span class=\"hljs-string\">\"image\/png, image\/jpeg\"<\/span>\n      @<span class=\"hljs-attr\">change<\/span>=<span class=\"hljs-string\">\"handleFileChange($event.target)\"<\/span>\n      <span class=\"hljs-attr\">required<\/span>\n    \/&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h2<\/span> <span class=\"hljs-attr\">for<\/span>=<span class=\"hljs-string\">\"file-input\"<\/span>&gt;<\/span>Click or Drag N Drop Image<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h2<\/span>&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">img<\/span> <span class=\"hljs-attr\">v-bind:src<\/span>=<span class=\"hljs-string\">\"preview\"<\/span> \/&gt;<\/span>\n    <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h3<\/span> <span class=\"hljs-attr\">v-if<\/span>=<span class=\"hljs-string\">\"preview\"<\/span>&gt;<\/span>File name: {{ fileName }}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h3<\/span>&gt;<\/span>\n  <span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">div<\/span>&gt;<\/span>\n\n  <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">button<\/span> <span class=\"hljs-attr\">type<\/span>=<span class=\"hljs-string\">\"submit\"<\/span> <span class=\"hljs-attr\">v-on:click<\/span>=<span class=\"hljs-string\">\"upload\"<\/span>&gt;<\/span>Upload<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">button<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">template<\/span>&gt;<\/span>\n\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">script<\/span>&gt;<\/span><span class=\"javascript\">\n<span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">default<\/span> {\n  <span class=\"hljs-attr\">name<\/span>: <span class=\"hljs-string\">\"App\"<\/span>,\n  data() {\n    <span class=\"hljs-keyword\">return<\/span> {\n      <span class=\"hljs-attr\">fileName<\/span>: <span class=\"hljs-string\">\"\"<\/span>,\n      <span class=\"hljs-attr\">preview<\/span>: <span class=\"hljs-literal\">null<\/span>,\n      <span class=\"hljs-attr\">preset<\/span>: process.env.VUE_APP_UPLOAD_PRESET,\n      <span class=\"hljs-attr\">formData<\/span>: <span class=\"hljs-literal\">null<\/span>,\n      <span class=\"hljs-attr\">cloudName<\/span>: process.env.VUE_APP_CLOUD_NAME,\n      <span class=\"hljs-attr\">success<\/span>: <span class=\"hljs-string\">\"\"<\/span>,\n    };\n  },\n  <span class=\"hljs-attr\">methods<\/span>: {\n    <span class=\"hljs-attr\">handleFileChange<\/span>: <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> (<span class=\"hljs-params\">event<\/span>) <\/span>{\n      <span class=\"hljs-keyword\">this<\/span>.file = event.files&#91;<span class=\"hljs-number\">0<\/span>];\n      <span class=\"hljs-keyword\">this<\/span>.fileName = <span class=\"hljs-keyword\">this<\/span>.file.name;\n\n      <span class=\"hljs-keyword\">this<\/span>.formData = <span class=\"hljs-keyword\">new<\/span> FormData();\n      <span class=\"hljs-keyword\">this<\/span>.formData.append(<span class=\"hljs-string\">\"upload_preset\"<\/span>, <span class=\"hljs-keyword\">this<\/span>.preset);\n\n      <span class=\"hljs-keyword\">let<\/span> reader = <span class=\"hljs-keyword\">new<\/span> FileReader();\n      reader.readAsDataURL(<span class=\"hljs-keyword\">this<\/span>.file);\n\n      reader.onload = <span class=\"hljs-function\">(<span class=\"hljs-params\">e<\/span>) =&gt;<\/span> {\n        <span class=\"hljs-keyword\">this<\/span>.preview = e.target.result;\n        <span class=\"hljs-keyword\">this<\/span>.formData.append(<span class=\"hljs-string\">\"file\"<\/span>, <span class=\"hljs-keyword\">this<\/span>.preview);\n      };\n    },\n  },\n};\n<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">script<\/span>&gt;<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>In the above code, you create a dropzone for dropping the images using <code>@dragover<\/code>, <code>@dragenter<\/code>, <code>@dragstart<\/code>, and <code>@drop<\/code> event handlers. The function <code>handleFileChange()<\/code> is triggered when selecting an image either by drag and drop operation or using the <code>input<\/code> element.<\/p>\n<p>If an image is dropped in the dropzone, the <code>DataTransfer<\/code> object is passed to the <code>handleFileChange()<\/code> function. If a user selects an image using the <code>input<\/code> element, the <code>target<\/code> object is passed to the <code>handleFileChange()<\/code> function.<\/p>\n<p>This function uses <code>FileReader<\/code> API to read the contents of the image and convert it to a <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Basics_of_HTTP\/Data_URIs\">data URL<\/a> from a <code>File<\/code> Object. File objects are obtained either from a <code>FileList<\/code> object returned due to a user selecting files using the <code>&lt;input&gt;<\/code> element or from a drag and drop operation\u2019s <code>DataTransfer<\/code> object.<\/p>\n<p>The <code>FileReader<\/code> API converts the image to a <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Basics_of_HTTP\/Data_URIs\">Data URL<\/a> using <code>readAsDataURL()<\/code> and <code>onload()<\/code> functions and is stored inside the <code>preview<\/code> variable. You can read more about <code>readAsDataURL()<\/code> <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/FileReader\/readAsDataURL\">here<\/a>.<\/p>\n<p>You also store the name of the image in a variable named <code>fileName<\/code>. Both the name and the image selected are displayed to the user using the <code>v-if<\/code> directive. You can read more about this directive <a href=\"https:\/\/vuejs.org\/v2\/guide\/conditional.html\">here<\/a>.<\/p>\n<p>The data URL of the image or <code>preview<\/code> variable is appended to a <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/FormData\">FormData<\/a> along with the <code>upload_preset<\/code>. This <code>formData<\/code> is sent to the API in the request body when the user clicks the <code>Upload<\/code> button triggering the <code>upload()<\/code> function. You will create the <code>upload()<\/code> function in the next section.<\/p>\n<p>Here is how your app will look like.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1622376526\/e-603fc45fe6c0b4006873802f\/hxxsb1wrjgan5s1sezzu.png\" alt=\"App without Styles\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1920\" height=\"908\"\/><\/p>\n<p>Here is how your app looks after selecting or dragging\/dropping an image. You can see the chosen image and its name on the app with the help of the <code>fileName<\/code> and <code>preview<\/code> variables.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1622376585\/e-603fc45fe6c0b4006873802f\/fvlqow1g4dzphmauyz0a.png\" alt=\"App without styles with Image seleccted\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1920\" height=\"908\"\/><\/p>\n<p>You can style the app by copying and pasting the following code to the <code>style<\/code> section.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">style<\/span>&gt;<\/span><span class=\"css\">\n<span class=\"hljs-selector-id\">#app<\/span> {\n  <span class=\"hljs-attribute\">font-family<\/span>: Avenir, Helvetica, Arial, sans-serif;\n  <span class=\"hljs-attribute\">-webkit-font-smoothing<\/span>: antialiased;\n  <span class=\"hljs-attribute\">-moz-osx-font-smoothing<\/span>: grayscale;\n  <span class=\"hljs-attribute\">text-align<\/span>: center;\n  <span class=\"hljs-attribute\">color<\/span>: <span class=\"hljs-number\">#2c3e50<\/span>;\n  <span class=\"hljs-attribute\">margin-top<\/span>: <span class=\"hljs-number\">60px<\/span>;\n    <span class=\"hljs-attribute\">display<\/span>: flex;\n  <span class=\"hljs-attribute\">flex-direction<\/span>: column;\n\n}\n<span class=\"hljs-selector-class\">.dropzone<\/span> {\n  <span class=\"hljs-attribute\">height<\/span>: fit-content;\n  <span class=\"hljs-attribute\">min-height<\/span>: <span class=\"hljs-number\">200px<\/span>;\n  <span class=\"hljs-attribute\">max-height<\/span>: <span class=\"hljs-number\">400px<\/span>;\n  <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">600px<\/span>;\n  <span class=\"hljs-attribute\">background<\/span>: <span class=\"hljs-number\">#fdfdfd<\/span>;\n  <span class=\"hljs-attribute\">border-radius<\/span>: <span class=\"hljs-number\">5px<\/span>;\n  <span class=\"hljs-attribute\">border<\/span>: <span class=\"hljs-number\">2px<\/span> dashed <span class=\"hljs-number\">#000<\/span>;\n  <span class=\"hljs-attribute\">display<\/span>: flex;\n  <span class=\"hljs-attribute\">flex-direction<\/span>: column;\n  <span class=\"hljs-attribute\">justify-content<\/span>: center;\n  <span class=\"hljs-attribute\">align-items<\/span>: center;\n  <span class=\"hljs-attribute\">margin<\/span>: <span class=\"hljs-number\">0<\/span> auto;\n}\n<span class=\"hljs-selector-tag\">input<\/span><span class=\"hljs-selector-attr\">&#91;type=<span class=\"hljs-string\">\"file\"<\/span>]<\/span> {\n  <span class=\"hljs-attribute\">position<\/span>: absolute;\n  <span class=\"hljs-attribute\">opacity<\/span>: <span class=\"hljs-number\">0<\/span>;\n  <span class=\"hljs-attribute\">width<\/span>: inherit;\n  <span class=\"hljs-attribute\">min-height<\/span>: <span class=\"hljs-number\">200px<\/span>;\n  <span class=\"hljs-attribute\">max-height<\/span>: <span class=\"hljs-number\">400px<\/span>;\n  <span class=\"hljs-attribute\">cursor<\/span>: pointer;\n}\n\n<span class=\"hljs-selector-tag\">img<\/span> {\n  <span class=\"hljs-attribute\">width<\/span>: <span class=\"hljs-number\">50%<\/span>;\n  <span class=\"hljs-attribute\">height<\/span>: <span class=\"hljs-number\">50%<\/span>;\n}\n<span class=\"hljs-selector-tag\">button<\/span> {\n  <span class=\"hljs-attribute\">background-color<\/span>: transparent;\n  <span class=\"hljs-attribute\">border<\/span>: <span class=\"hljs-number\">2px<\/span> solid <span class=\"hljs-number\">#e74c3c<\/span>;\n  <span class=\"hljs-attribute\">border-radius<\/span>: <span class=\"hljs-number\">1em<\/span>;\n  <span class=\"hljs-attribute\">color<\/span>: <span class=\"hljs-number\">#e74c3c<\/span>;\n  <span class=\"hljs-attribute\">cursor<\/span>: pointer;\n  <span class=\"hljs-attribute\">display<\/span>: flex;\n  <span class=\"hljs-attribute\">align-self<\/span>: center;\n  <span class=\"hljs-attribute\">font-size<\/span>: <span class=\"hljs-number\">1rem<\/span>;\n  <span class=\"hljs-attribute\">margin<\/span>: <span class=\"hljs-number\">20px<\/span>;\n  <span class=\"hljs-attribute\">padding<\/span>: <span class=\"hljs-number\">1.2em<\/span> <span class=\"hljs-number\">2.4em<\/span>;\n  <span class=\"hljs-attribute\">text-align<\/span>: center;\n  <span class=\"hljs-attribute\">text-transform<\/span>: uppercase;\n  <span class=\"hljs-attribute\">font-family<\/span>: <span class=\"hljs-string\">\"Montserrat\"<\/span>, sans-serif;\n  <span class=\"hljs-attribute\">font-weight<\/span>: <span class=\"hljs-number\">700<\/span>;\n}\n<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">style<\/span>&gt;<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>You can also use UI libraries like <a href=\"https:\/\/bootstrap-vue.org\/\">BootstrapVue<\/a>, <a href=\"https:\/\/vuetifyjs.com\/en\/\">Vuetify<\/a>, etc., to style the app. Here is how your app will look like.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1622376625\/e-603fc45fe6c0b4006873802f\/i8fcpohqgkojkqy5kltp.png\" alt=\"App with styles\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"1920\" height=\"908\"\/><\/p>\n<h2>How To Upload the Image to Cloudinary<\/h2>\n<p>Under <code>script<\/code> \u2192 <code>methods<\/code> create a function named <code>upload<\/code> that makes a POST request to <a href=\"https:\/\/api.cloudinary.com\">https:\/\/api.cloudinary.com<\/a> with the request body being <code>formData<\/code> containing the <code>file<\/code> or data URL and the unsigned <code>upload_preset<\/code>.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript shcb-wrap-lines\">upload: <span class=\"hljs-keyword\">async<\/span> <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> (<span class=\"hljs-params\"><\/span>) <\/span>{\n\t\t<span class=\"hljs-keyword\">const<\/span> res = <span class=\"hljs-keyword\">await<\/span> fetch(\n\t\t  <span class=\"hljs-string\">`https:\/\/api.cloudinary.com\/v1_1\/<span class=\"hljs-subst\">${<span class=\"hljs-keyword\">this<\/span>.cloudName}<\/span>\/image\/upload`<\/span>,\n\t\t  {\n\t\t    <span class=\"hljs-attr\">method<\/span>: <span class=\"hljs-string\">\"POST\"<\/span>,\n\t\t    <span class=\"hljs-attr\">body<\/span>: <span class=\"hljs-keyword\">this<\/span>.formData,\n\t\t  }\n\t\t);\n\t\t<span class=\"hljs-keyword\">const<\/span> data = <span class=\"hljs-keyword\">await<\/span> res.json();\n\t\t<span class=\"hljs-keyword\">this<\/span>.fileName = <span class=\"hljs-string\">\"\"<\/span>;\n\t\t<span class=\"hljs-keyword\">this<\/span>.preview = <span class=\"hljs-literal\">null<\/span>;\n\t\t<span class=\"hljs-keyword\">this<\/span>.formData = <span class=\"hljs-literal\">null<\/span>;\n\t\t<span class=\"hljs-keyword\">this<\/span>.success = data.public_id;\n},\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>After sending the POST request, you reset <code>fileName<\/code>, <code>preview<\/code>, and <code>formData<\/code> to their initial values. You also store the <code>public_id<\/code> of the image in the <code>success<\/code> variable, which is then displayed to the user.<\/p>\n<p>Add the following code after the <code>button<\/code> in the <code>template<\/code> section. This code is displayed after a successful response is returned from the API, and <code>success<\/code> is not equal to empty strings.<\/p>\n<pre class=\"js-syntax-highlighted\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-wrap-lines\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h3<\/span> <span class=\"hljs-attr\">v-if<\/span>=<span class=\"hljs-string\">\"success\"<\/span>&gt;<\/span>File Uploaded Successfully. publicId: {{success}}<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h3<\/span>&gt;<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n<p>Here is the entire upload operation in action.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/jesse-thisdot\/image\/upload\/c_limit,w_2000\/f_auto\/q_auto\/v1622376658\/e-603fc45fe6c0b4006873802f\/fz1br4s7o1ik1d1c5ovn.gif\" alt=\"Upload Operation GIF\" loading=\"lazy\" class=\"c-transformed-asset\"  width=\"600\" height=\"284\"\/><\/p>\n<p>After successful upload, the <code>public_id<\/code> of the image is displayed on the app.<\/p>\n<h2>Conclusion<\/h2>\n<p>In this media jam, we saw how to upload images to Cloudinary in Vue.js with drag and drop operation.\nYou uploaded a picture with an unsigned preset in this jam, but you can also upload a picture with a signed preset. For this, you will need to append <code>api_key<\/code>, <code>timestamp<\/code>, and <code>signature<\/code> in the form data along with the <code>file<\/code>.<\/p>\n<p>Here are some additional resources that can be helpful:<\/p>\n<ul>\n<li>\n<a href=\"https:\/\/cloudinary.com\/documentation\/upload_images#uploading_with_a_direct_call_to_the_rest_api\">Cloudinary Docs -Uploading with a direct call to the REST API<\/a>\n<\/li>\n<li>\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/FileReader\">File Reader API<\/a>\n<\/li>\n<li>\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/HTML_Drag_and_Drop_API\">HTML Drag and Drop API<\/a>\n<\/li>\n<\/ul>\n<\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":41,"featured_media":28250,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_cloudinary_featured_overwrite":false,"footnotes":""},"categories":[1],"tags":[134,371,373,315],"class_list":["post-28249","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-guest-post","tag-under-review","tag-upload","tag-vue"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.6 (Yoast SEO v26.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Upload Images in Vue.js with Drag N Drop<\/title>\n<meta name=\"description\" content=\"According to Stack Overflow 2020 survey, Vue.js was one of the Most Loved Web frameworks of the developers. In this media jam, we will see how to upload an image to Cloudinary with a drag and drop operation.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Upload Images in Vue.js with Drag N Drop\" \/>\n<meta property=\"og:description\" content=\"According to Stack Overflow 2020 survey, Vue.js was one of the Most Loved Web frameworks of the developers. In this media jam, we will see how to upload an image to Cloudinary with a drag and drop operation.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloudinary Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-02T08:55:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-09T01:07:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/v1681925023\/Web_Assets\/blog\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48-png?_i=AA\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"909\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"NewsArticle\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/\"},\"author\":{\"name\":\"\",\"@id\":\"\"},\"headline\":\"How to Upload Images in Vue.js with Drag N Drop\",\"datePublished\":\"2021-06-02T08:55:02+00:00\",\"dateModified\":\"2025-02-09T01:07:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/\"},\"wordCount\":11,\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925023\/Web_Assets\/blog\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48.png?_i=AA\",\"keywords\":[\"Guest Post\",\"Under Review\",\"Upload\",\"Vue\"],\"inLanguage\":\"en-US\",\"copyrightYear\":\"2021\",\"copyrightHolder\":{\"@id\":\"https:\/\/cloudinary.com\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/\",\"url\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/\",\"name\":\"How to Upload Images in Vue.js with Drag N Drop\",\"isPartOf\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925023\/Web_Assets\/blog\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48.png?_i=AA\",\"datePublished\":\"2021-06-02T08:55:02+00:00\",\"dateModified\":\"2025-02-09T01:07:30+00:00\",\"description\":\"According to Stack Overflow 2020 survey, Vue.js was one of the Most Loved Web frameworks of the developers. In this media jam, we will see how to upload an image to Cloudinary with a drag and drop operation.\",\"breadcrumb\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/#primaryimage\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925023\/Web_Assets\/blog\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925023\/Web_Assets\/blog\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48.png?_i=AA\",\"width\":1920,\"height\":909},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/cloudinary.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Upload Images in Vue.js with Drag N Drop\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#website\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"name\":\"Cloudinary Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/cloudinary.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#organization\",\"name\":\"Cloudinary Blog\",\"url\":\"https:\/\/cloudinary.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"contentUrl\":\"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA\",\"width\":312,\"height\":60,\"caption\":\"Cloudinary Blog\"},\"image\":{\"@id\":\"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Upload Images in Vue.js with Drag N Drop","description":"According to Stack Overflow 2020 survey, Vue.js was one of the Most Loved Web frameworks of the developers. In this media jam, we will see how to upload an image to Cloudinary with a drag and drop operation.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/","og_locale":"en_US","og_type":"article","og_title":"How to Upload Images in Vue.js with Drag N Drop","og_description":"According to Stack Overflow 2020 survey, Vue.js was one of the Most Loved Web frameworks of the developers. In this media jam, we will see how to upload an image to Cloudinary with a drag and drop operation.","og_url":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/","og_site_name":"Cloudinary Blog","article_published_time":"2021-06-02T08:55:02+00:00","article_modified_time":"2025-02-09T01:07:30+00:00","og_image":[{"width":1920,"height":909,"url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/v1681925023\/Web_Assets\/blog\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48-png?_i=AA","type":"image\/png"}],"twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/#article","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/"},"author":{"name":"","@id":""},"headline":"How to Upload Images in Vue.js with Drag N Drop","datePublished":"2021-06-02T08:55:02+00:00","dateModified":"2025-02-09T01:07:30+00:00","mainEntityOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/"},"wordCount":11,"publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925023\/Web_Assets\/blog\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48.png?_i=AA","keywords":["Guest Post","Under Review","Upload","Vue"],"inLanguage":"en-US","copyrightYear":"2021","copyrightHolder":{"@id":"https:\/\/cloudinary.com\/#organization"}},{"@type":"WebPage","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/","url":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/","name":"How to Upload Images in Vue.js with Drag N Drop","isPartOf":{"@id":"https:\/\/cloudinary.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/#primaryimage"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/#primaryimage"},"thumbnailUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925023\/Web_Assets\/blog\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48.png?_i=AA","datePublished":"2021-06-02T08:55:02+00:00","dateModified":"2025-02-09T01:07:30+00:00","description":"According to Stack Overflow 2020 survey, Vue.js was one of the Most Loved Web frameworks of the developers. In this media jam, we will see how to upload an image to Cloudinary with a drag and drop operation.","breadcrumb":{"@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/#primaryimage","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925023\/Web_Assets\/blog\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925023\/Web_Assets\/blog\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48.png?_i=AA","width":1920,"height":909},{"@type":"BreadcrumbList","@id":"https:\/\/cloudinary.com\/blog\/guest_post\/how-to-upload-images-in-vue-js-with-drag-n-drop\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/cloudinary.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Upload Images in Vue.js with Drag N Drop"}]},{"@type":"WebSite","@id":"https:\/\/cloudinary.com\/blog\/#website","url":"https:\/\/cloudinary.com\/blog\/","name":"Cloudinary Blog","description":"","publisher":{"@id":"https:\/\/cloudinary.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/cloudinary.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/cloudinary.com\/blog\/#organization","name":"Cloudinary Blog","url":"https:\/\/cloudinary.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","contentUrl":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1649718331\/Web_Assets\/blog\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877\/cloudinary_logo_for_white_bg_1937437aa7_19374666c7_193742f877.png?_i=AA","width":312,"height":60,"caption":"Cloudinary Blog"},"image":{"@id":"https:\/\/cloudinary.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":""}]}},"jetpack_featured_media_url":"https:\/\/res.cloudinary.com\/cloudinary-marketing\/images\/f_auto,q_auto\/v1681925023\/Web_Assets\/blog\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48\/fa9fd989ed9a5872f92943a104bb4e64f936ac98-1920x909-1_2825013b48.png?_i=AA","_links":{"self":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28249","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/comments?post=28249"}],"version-history":[{"count":1,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28249\/revisions"}],"predecessor-version":[{"id":36748,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/posts\/28249\/revisions\/36748"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media\/28250"}],"wp:attachment":[{"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/media?parent=28249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/categories?post=28249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cloudinary.com\/blog\/wp-json\/wp\/v2\/tags?post=28249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}