in reply to Re^2: How to download a file from the server (content disposition CGI->header( qw{ -type mime/type -attachment filename } ) )
in thread How to download a file from the server

Sorry , I did not get how to use it and it still not working. Can you please elaborate ?

The code you posted, the headers it generates, doesn't match the headers CGI::header generates

  • Comment on Re^3: How to download a file from the server (content disposition CGI->header( qw{ -type mime/type -attachment filename } ) )

Replies are listed 'Best First'.
Re^4: How to download a file from the server (content disposition CGI->header( qw{ -type mime/type -attachment filename } ) )
by ghosh123 (Monk) on Jul 24, 2013 at 10:53 UTC

    Hi ,
    The downloading is working now for simple text files. For downloading excel file (.xls) I am using the following content but the files are getting downloaded of 0 bytes size and corrupted.
    I am using following content type for excel but of no use. Please help.

    print "Content-Type:application/vnd.ms-excel\n"; print "Content-Disposition:attachment;filename=data.xls\n\n";

      I recommend looking at a network dump and inspecting the web server error logs.

      Also, you may want to binmode the socket when sending binary data. You also want to send a Content-Length header and a HTTP response code. Maybe you want to use HTTP::Response or CGI to create the response output?

      Update: You're already using binmode.

        Update: You're already using binmode.

        Half the time :)

      downloaded of 0 bytes size and corrupted.

      Thats impossible