Uploading images keep a copy of the original in PhP's "tmp" folder

I noticed that a copy of every uploaded original image is kept in PhP’s temporary “tmp” folder (I don’t know if this happens on uploads or on thumbs generation). That created an issue for me as I was uploading a lot of images and the temporary folder got full and had to be cleared manually (I read somewhere on the forum that this issue had happened to someone else) in order to continue uploading images.

I’m wondering if this behaviour is normal or if the original file should be deleted from the temporary folder after the image has been uploaded and/or thumbs generated?

That is usually the case according to the php manual:

The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed

However, the script renames the file for better mime type detection and that’s why it is not automatically removed (the same happens when you do this outside of Kirby).

I don’t know if this is the intended behavior or if you have to deal with this via of clean up script (cron job) or whether shared hosting servers do regular cleanups anyway…

I created an issue: