Hi all,
I have some problem while downloading a file from my server. My code works fine. But downloaded file format is not correct.
My code is as follows .. This code will download a .txt file from server to client machine.
$target_file="filepath"; print "Content-Type: application/x-unknown\n"; print "Content-Disposition: attachment; filename=$flid\n\n"; $output_file = read_file($target_file); print $output_file; sub read_file { local($fname) = @_; local($content); open(FILE, "<$fname") || print "cannot open ".$!; while(<FILE>) { $content .= $_; } close(FILE); return $content; }

and file content is stored in a .txt file and looks like
vy01hc jy02vl hr80je tx92fs qs13kj kk96bg bw95oz st81lv zh64yz vg27tp

but downloded file content in a single line and some extra character in between each line.
Please provide a guideline to solve this problem.
Thanks
sur

In reply to Downloading file by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.