Use the functions provided by the CGI module. You should define the form with 'start_multipart_form()' and the upload field with 'filefield()'. The file is uploaded to a temporary location; you have to write to another location in order to keep it.