mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-12-29 19:05:05 +08:00
dragdrop: add error handling for URLs
This commit is contained in:
parent
83a9dd82db
commit
446cd5a58b
19
javascript/dragdrop.js
vendored
19
javascript/dragdrop.js
vendored
@ -93,11 +93,20 @@ window.document.addEventListener('drop', async e => {
|
||||
fileInput.files = files;
|
||||
fileInput.dispatchEvent(new Event('change'));
|
||||
} else if (url) {
|
||||
const request = await fetch(url);
|
||||
const data = new DataTransfer();
|
||||
data.items.add(new File([await request.blob()], 'image.png'));
|
||||
fileInput.files = data.files;
|
||||
fileInput.dispatchEvent(new Event('change'));
|
||||
try {
|
||||
const request = await fetch(url);
|
||||
if (!request.ok) {
|
||||
console.error('Error fetching URL:', url, request.status);
|
||||
return;
|
||||
}
|
||||
const data = new DataTransfer();
|
||||
data.items.add(new File([await request.blob()], 'image.png'));
|
||||
fileInput.files = data.files;
|
||||
fileInput.dispatchEvent(new Event('change'));
|
||||
} catch (error) {
|
||||
console.error('Error fetching URL:', url, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user