use URI::Escape; .... $fname = uri_escape($fname); .... print "Content-length: $fsize\n"; print "Content-Disposition: attachment; filename=$fname\n"; print "Content-Type: application/force-download;\n\n"; ....