my $query=new CGI(); my $filename=$query->upload("uploaded_file"); if( defined($filename) ) { # save the uploaded file open(OUTPUT, ">1.jpg"); # just an example, you should check the type binmode($filename); binmode(OUTPUT); while( read($filename, $buffer, 64*2**10) ) { # filename is a file handle here print OUTPUT $buffer; } close(OUTPUT); print $query->header(); print $filename; # it's a string here; original filename returned (the name on client's harddrive, fullpath/filename } else { # print the form print $query->header(); ... print $query->end_html(); }