sub read_binary { local($fname) = @_; open(FILE, "<$fname") || return ''; while(){ $spcontent .= $_; } close(FILE); $spcontent; } sub dl_user { ($loc)=@_; $filename = $loc; $filename =~ s/.+\/([^\/]+)$/$1/; $filename =~ s/.+\\([^\\]+)$/$1/; print "Content-Type: application/x-binary\n"; print"Content-Disposition:attachment;filename=$filename\n\n"; &read_binary($loc); }