How to Handle File Uploads

Can anyone tell me if this code still works or if there is a better way of doing it now?

For example is this a better solution to use?