Results 1 to 5 of 5

Thread: Download zip file from site itself

  1. #1
    Join Date
    Feb 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Download zip file from site itself

    Hi All,


    Is this possible to keep downloading in the site itself ?
    ie) Instead of download popup ask save?open?cancel? then proceed downloading , i have to keep downloading in site itself like buffering?

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    No. Unless the file can be opened as a "web page", like images and some media (quicktime movies, for example), then a file must be downloaded. The browser determines this behavior.

    It is *theoretically* possible to design a way to download a file with a progress bar, but that would mean creating an applet based on a browser plugin to do that. I do not believe it would be very easy (maybe not possible) with flash, and I think this means you would have to use a Java applet. The only other option would be using ActiveX which only works in internet explorer. This would be a bad idea, though.
    Daniel - Freelance Web Design | <?php?> | <html>| espaņol | Deutsch | italiano | portuguęs | catalā | un peu de franįais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Feb 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks for reply.

  4. #4
    Join Date
    Feb 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Now im look into another methed.
    Im having following code


    PHP Code:
    //function to zip and force download the files using PHP
    function zipFilesAndDownload($file_names,$archive_file_name,$file_path)
    {
      
    //create the object
      
    $zip = new ZipArchive();
      
    //create the file and throw the error if unsuccessful
      
    if ($zip->open($archive_file_nameZIPARCHIVE::CREATE )!==TRUE) {
        exit(
    "cannot open <$archive_file_name>\n");
      }

      
    //add each files of $file_name array to archive
      
    foreach($file_names as $files)
      {
        
    $zip->addFile($file_path.$files,$files);
      }
      
    $zip->close();

      
    //then send the headers to foce download the zip file
      
    header("Content-type: application/zip");
      
    header("Content-Disposition: attachment; filename=$archive_file_name");
      
    header("Pragma: no-cache");
      
    header("Expires: 0");
      
    readfile("$archive_file_name");
      exit;

    PHP Code:
      $file_names=array('test.php','test1.txt');
      
    $archive_file_name='zipped.zip';
      
    $file_path=dirname(__FILE__).'/';
      
    zipFilesAndDownload($file_names,$archive_file_name,$file_path); 

    Here i have to rectify 2 problems
    1.Download code should ask save location
    2.One more copy is created in source location.If i upload this code into server, My server will be overloaded.

    How to resolve this? Plz help

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I don't understand. This is the opposite of what you want. This creates a zip file that will do the DEFAULT behavior: it will popup and ask where you want to save it or if you want to open it, like any normal zip file: this is just converting OTHER files to zip files. According to your first post, this is not what you want.

    1. The browser will determine where it saves. Many will let the user choose (either for each download individually or create a general setting for where to save).
    2. I don't understand. If your server will be overloaded, then don't use this code or get a better server. If you decide you want to store the file on the server, then just use fopen() fwrite() fclose() etc-- look at php.net for info on those. There are examples.
    Daniel - Freelance Web Design | <?php?> | <html>| espaņol | Deutsch | italiano | portuguęs | catalā | un peu de franįais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •