in reply to pop up Save as box before downloading

You don't state which framework/how you're serving content. Depending on what this is there's various ways to set the Content-Disposition. Perhaps if you explain how you're doing this specific solutions could be provided.

  • Comment on Re: pop up Save as box before downloading

Replies are listed 'Best First'.
Re^2: pop up Save as box before downloading
by pearlgirl (Novice) on Nov 08, 2023 at 18:59 UTC
    It's a web based application, we're using ActiveState. Once the user gets to the page we pull the information from the database and when the Download button is clicked, we need to save the data into a comma delimited text file, but it's very important that the user can choose where to save the file. Thank you for the Content-Disposition suggestion..reading about it now

      That's the version of perl and the platform, but nothing about your code. Assuming this is CGI based something like the following before serving your file:

      print $q->header( -type => "application/x-download", -'Content-Disposition' => 'attachment; filename="FileNameGoesH +ere.csv"' );

      If you aren't using CGI, post some code to get better answers :)

      It's a web based application, we're using ActiveState.

      That's just a way to get Perl on Windows (and not the best one, IMHO).

      when the Download button is clicked, we need to save the data into a comma delimited text file, but it's very important that the user can choose where to save the file

      In general, web browsers can be asked to do "things", and you can suggest "things", but unlike with some specialized, proprietary clients, web browsers are free to ignore some or all of what you ask for and what you suggest.

      Usually, websites suggest a filename for downloads. In the most trivial case, by just using a URL that ends in the desired name, e.g. http://www.example.com/some/where/desired-name.bin. In that case, there are no extra "instructions" for the web browser, and so the browser may choose to download the file or to display it, depending on its MIME type and sometimes also depending on the extension of the filename (".bin"). Using the Content-Disposition header, especially with the value attachment, a website may suggest to download the file EVEN IF the browser could also display it. (The browser is still free to ignore the C-D header, but most browsers follow its suggestion.) The C-D header may be extended by a filename attribute, suggesting a file name. If the browser chooses to accept the suggestion, it usually uses that in a "save as" dialog. Drive letters and directories in the filename attribute are usually removed. If there is no filename attribute, browsers usually fall back to extracting a filename from the URL.

      You may try to avoid suggesting a filename, e.g. by using a URL ending in a "/" AND omitting the filename attribute for the C-D header.

      If you have control over the user's browser choice (i.e. closed intranet instead of open internet), you can try to find and play tricks that work only with the selected browser.

      Otherwise, you could ask on the website for a filename and use that in the download URL and/or the C-D header.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)