# Cannot Delete Image

**URL:** <https://forum.inductiveautomation.com/t/cannot-delete-image/82313>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [November 24, 2023, 2:41am UTC](https://forum.inductiveautomation.com/t/cannot-delete-image/82313 "2023-11-24T02:41:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![illank86](https://avatars.discourse-cdn.com/v4/letter/i/c77e96/32.png) [@illank86](https://forum.inductiveautomation.com/u/illank86)\
**Post date:** [November 24, 2023, 2:41am UTC](https://forum.inductiveautomation.com/t/cannot-delete-image/82313/1 "2023-11-24T02:41:03Z")

</div>

Hi All,

i built function where user can upload an image but i have problem with deleting Image from webserver after using it in image component. The image locked by java.exe

I have use os.remove, but access denied.  
delete it in from windows folder, same result.

how can i delete file or image from webserver without restarting the gateway.

FYI, i put all my image on the webserver folder, since i need to expose all document and images to the perpsctive client.

Thanks

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [November 24, 2023, 3:06am UTC](https://forum.inductiveautomation.com/t/cannot-delete-image/82313/2 "2023-11-24T03:06:48Z")

</div>

~~This is Perspective?~~  
**Edit:**

> [@illank86](#):
>
> yes

Thanks. I added the tag to your post

---

<div class="post-metadata">

**Author:** ![illank86](https://avatars.discourse-cdn.com/v4/letter/i/c77e96/32.png) [@illank86](https://forum.inductiveautomation.com/u/illank86)\
**Post date:** [November 24, 2023, 3:12am UTC](https://forum.inductiveautomation.com/t/cannot-delete-image/82313/3 "2023-11-24T03:12:59Z")

</div>

yes, this is perspective

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [November 24, 2023, 8:57am UTC](https://forum.inductiveautomation.com/t/cannot-delete-image/82313/4 "2023-11-24T08:57:30Z")

</div>

You'll need to unblock the file, i've posted some tools to do this here

> [@Unblock and Delete files that have been locked by Java](https://forum.inductiveautomation.com/t/unblock-and-delete-files-that-have-been-locked-by-java/60194):
>
> There is an issue with java locking files that are in use. Mainly when using the webserver. Causing it to be impossible to delete them while the gateway is running. But here is a solution! (For windows atleast). Using handle you can find and unlock files. I made it a bit easier to use by writing a simple bat file. [UnlockAndDelete.zip](https://forum.inductiveautomation.com/uploads/short-url/7eEcAE6JGpz4JvjlyqUCP4CCD1X.zip) (891.3 KB) Unzip on the pc in the gateway (in for example C:\Folder) You can execute this through script or in the cmd line, requires admin rights! script: …

---

<div class="post-metadata">

**Author:** ![illank86](https://avatars.discourse-cdn.com/v4/letter/i/c77e96/32.png) [@illank86](https://forum.inductiveautomation.com/u/illank86)\
**Post date:** [November 24, 2023, 10:43am UTC](https://forum.inductiveautomation.com/t/cannot-delete-image/82313/5 "2023-11-24T10:43:53Z")

</div>

Hi @victordcq,

Thanks for the reply, but, is there an option to use internal ignition scripting instead of using another application which can lead to inconsistent behavior?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [November 24, 2023, 11:17am UTC](https://forum.inductiveautomation.com/t/cannot-delete-image/82313/6 "2023-11-24T11:17:30Z")

</div>

You can trigger the script from inside igntion, but it does require the bat file/ windows handle that is also in the zip folder.

I dont know if there are other ways than using handle. Its been a while that i made the post, but i had to search quite a while before i found somthing that worked. As far as i found Java has no way to unluck the file. Its a windows thing

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 24, 2023, 2:43pm UTC](https://forum.inductiveautomation.com/t/cannot-delete-image/82313/7 "2023-11-24T14:43:03Z")

</div>

Using the webserver folder to host files is **not supported** , in part because this java behavior cannot be changed.

Use the WebDev module to serve arbitrary files.

If you have the option to store your images as "blobs" in a database, you could use my free Blob Server module instead.
