in reply to File upload script printing to closed filehandle

jZed is absolutely right, the error is most likely caused by your call to open not opening the file. I would go on to suggest that the likely reason for this is that "/pics" is not a top-level directory on your machine but is rather a sub-directory of your web root. So you should set your $upload_dir to a path (absolute or relative) to the actual directory where the file should go.