It’s something you only have to write once in a while, but storing binary files in your database can be a useful thing. I found this excellent tutorial on Uploading, Saving and Downloading Binary Data in a MySQL Database. It’s a great overview of file uploading in PHP as well as dealing with BLOBs in your database.
The tutorial was written in 2000, so it’s a bit outdated. These days one needs to access the uploaded file information using the $_FILES[binFile] variable as described in the PHP File Upload documentation.