I have a blob image URL in my localhost (looks like "blob:http://localhost/1d795687-b478-4edf-9b3d-8dda768b9d9f") and I want to pick up this file and upload it to PHP using JavaScript.
I just want to know how to get this image as a file.
I have a blob image URL in my localhost (looks like "blob:http://localhost/1d795687-b478-4edf-9b3d-8dda768b9d9f") and I want to pick up this file and upload it to PHP using JavaScript.
I just want to know how to get this image as a file.
You should sent the file as formData. Then you save it directly as a blob in your server. You can use code like
let formData = new FormData();
formData.append(key, blobImage);
Make backend api call with formdata
I used let blob = await fetch(url).then(r => r.blob())
and it gave me a blob object with my image stored in local blob URL.
Code:
let blob = await fetch(url).then(r => r.blob());
var data = new FormData();
data.append('image', blob, 'image.jpg');
Then, just send data
to PHP.