The XMLHttpRequest allows you to make an HTTP request and receive a response, but it does not give you access to the file system. You cannot delete files without access to them.
Solution 1 :
Problem :
I am creating an image viewer using XMLHttpRequest. It includes this function:
public view_image(_tImagen: iConfigImagen){
var img_view = this.prop_div_vizualizador;
var _window: any = window;
var xhr = new XMLHttpRequest();
xhr.open("GET", _tImagen.url, true);
xhr.responseType = "blob";
xhr.onload = function () {
var urlCreator = _window.URL = _window.URL || _window.webkitURL;
var imageUrl = urlCreator.createObjectURL(this.response);
_tImagen.urlBlob = imageUrl;
img_view.style("background-image", "url(" + _tImagen.urlBlob + ")");
}
}
It works fine, but I am trying to delete the blob files that it generates somehow. I tried URL.revokeObjectURL(url)
, but that only deletes the url and not the file. How can I delete the files? Is there any way to remove them?
Thanks in advance.
Comments
Comment posted by Teemu
Do you mean you want to delete the files on the disk? That’s not possible using JS.
Comment posted by Jorge.
Yes, they are only deleted when I refresh the page. So there is no way to eliminate them?