I do not think it is your code that refresh page but your server that "listens" to file changes, if a folder has changed it will refresh your pages.
See more on subject HERE.
You probably have server on watch mode. so when you upload a file, the watcher detects something change on disk and reload.
find that option and turn it off.
alternatively, some watchers have option to ignore certain folder. you can add that images folder to ignore list.
to disable watch mode for certain files/folders, do like this