Results 1 to 1 of 1

Thread: Kitchen development - downloading update zip files from Web using headers (PHP)

777
  1. [translate]    #1
    Senior Member
    Join Date
    Jun 2010
    Location
    Portugal
    Posts
    789

    Default Kitchen development - downloading update zip files from Web using headers (PHP)

    Guys I made a little kitchen and the update files when copied from the web app directory are fine and correctly works. However when are downloaded from web browser ("save as") the Spica recovery says: "cant open something.zip (bad). I dont understand why, the structure and the files are exactly the same than the original, however the file is couple of KB larger than the original (the one it works). the /system and /META-INF folders has the same size (than the original) but the zip itself is for some reason larger - and that reason it's not accepted by recovery.

    I tried several ways:

    $zipfile is "something.zip".

    Code:
    header("Cache-Control: public");
        header("Content-Description: File Transfer");
        header("Content-Disposition: attachment; filename=$zipfile");
        header("Content-Type: application/zip");
        header("Content-Transfer-Encoding: binary");
         readfile($zipfile);
    
    or
    
            header("Content-type: application/zip");
    	header("Content-Disposition: attachment;filename=$zipfile");
    	readfile($zipfile);
    Anyone knows what could be wrong?

    EDIT, SOLVED

    Code:
    if (file_exists($zipfile)) {
    		header('Content-Description: File Transfer');
    		header('Content-Type: application/zip');
    		header('Content-Disposition: attachment; filename='.basename($zipfile));
    		header('Content-Transfer-Encoding: binary');
    		header('Expires: 0');
    		header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    		header('Pragma: public');
    		header('Content-Length: ' . filesize($zipfile));
    		ob_clean();
    		flush();
    		readfile($zipfile);
    		exit;
    	}
    Last edited by Maxxd; 04-10-2011 at 06:21 PM.
    Creator of apKitchen -> apkitchen.pt.vu

    Android App here

    CM+X 14.2

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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
  •