[Vuejs]-Pass url as a parameter in vue.js

0👍

You have many ways to handle this, I’ll mention two of them in the following:

  • Encode URI
HTTP://img.com/img.com --> http%3A%2F%2Fimg.com%2Fimg.jpg

And send it to the backend service, then you need to decode the string in the PHP by using urldecode() function.

let img_path = encodeURIComponent("HTTP://img.com/img.jpg")
  • Base64

You can also use btoa() to encode the URL and then send it to the backend. the only thing you need to do is decoding the URL to the origin one by using
base64_decode() in the PHP side.

Leave a comment