CGI, header, and redirect

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • FLUX (a l'Ircam)

    CGI, header, and redirect

    Hi Perl folk!

    I have the following problem :
    I want to upload a file (stored in a web server) to the browser, and then
    delete the file in the server. This file contains the results of a sound
    analysis/synthesis and is named XXX.zip with XXX the basename of the
    initial sound file...

    If I used: "redirect(-uri=>$UPLOAD_DI R/my_file.zip);"
    it would be OK, but then I can't delete the file after it is
    downloaded...

    So I did the following :
    <CODE>

    print header(-type=>'applicat ion/zip');
    open UPLOADFILE, "<$UPLOAD_D IR/$my_file.zip";
    binmode UPLOADFILE;
    while ( <UPLOADFILE> ){
    print ;
    }
    close UPLOADFILE;
    `rm -fr $UPLOAD_DIR/my_file.zip`;

    </CODE>

    But there is a big problem with that : when the user download the zip file
    it is named like the cgi script : for exemple "get_result.cgi " instead of
    "sound56.zi p"

    Is there a way to force a name? Maybe using an option in the header?
    I read the CGI.pm perldoc and googled it, but I could'nt find anything of
    value...

    PS : sorry if you find this question stupid, but I'm quite new to Perl...

    Flux

    --
    "Pour moi la programmation est plus qu'un art applique important, c'est
    aussi une ambitieuse quete menee dans les trefonds de la connaissance"

    Grace Hopper, inventeur du compilateur
  • FLUX (a l'Ircam)

    #2
    Solution (was CGI, header, and redirect)

    > print header(-type=>'applicat ion/zip');[color=blue]
    > open UPLOADFILE, "<$UPLOAD_D IR/$my_file.zip";
    > binmode UPLOADFILE;
    > while ( <UPLOADFILE> ){
    > print ;
    > }
    > close UPLOADFILE;
    > `rm -fr $UPLOAD_DIR/my_file.zip`;
    >
    > But there is a big problem with that : when the user download the zip file
    > it is named like the cgi script : for exemple "get_result.cgi " instead of
    > "sound56.zi p"
    >
    > Is there a way to force a name? Maybe using an option in the header?
    > I read the CGI.pm perldoc and googled it, but I could'nt find anything of
    > value...[/color]


    Well, I just found it! Sorry for the nuisance. Here is the solution :
    I had to use :
    ^^^^^^^^^^^^
    print header(-type=>"applicat ion/octet-stream", \
    -attachment=>"my _filezip");

    instead of :
    ^^^^^^^^^^
    print header(-type=>'applicat ion/zip');

    See you!

    Flux

    --
    "Pour moi la programmation est plus qu'un art applique important, c'est
    aussi une ambitieuse quete menee dans les trefonds de la connaissance"

    Grace Hopper, inventeur du compilateur

    Comment

    Working...