WP upload/select image , isn’t this a security issue?

Have no idea were that code snippet comes from but security for uploaded files should be addressed in three steps

  1. Upload permission should be restricted only to people you trust (assuming you are the admin/owner), and security is just part of the reason (think someone uploading porn to a church site)

  2. You should not let the php interpreter execute anything in the uploads directory. This will prevent people uploading and then executing rouge php scripts on your server.

  3. Any file which is not of an approved extension serve as a simple octet stream. Configured properly this will prevent people uploading JS and using them for cookie theft. A twist on it is to serve uploaded files from a different domain.

How to implement steps 2 and 3 depends on type of web sever you use.