are there problems with that code?
well, i shut off the loop. that's the biggest thing i could see going wrong.
as mentioned, i'd have much rather tried to figure out what the file type is first, but the api doesn't want you to do that - it forces you to do shit like this. it's cringey, in a sense, yes - you don't want to be pushing errors like this too much, as it opens up security issues. i wouldn't be surprised if i essentially just emulated a hacker routine. but, these files are local, and at least one of the arrays should work, or why are you doing this? as was the case with the buttons, the error handling is not good, but who cares, functionally? it works, and it will work so long as you don't get stupid about it.
i'm not sure i'd recommend this for any kind of internet application, though.