SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Download corrupt in IE but not Opera/Firefox

    Hey guys.

    I made a thread recently about download problems, specifically ie.

    Heres a prime example:

    http://www.myvouchercodes.co.uk/prin...ongtitle/48005
    Downloads fine in Firefox and IE7 and IE8.

    Whereas this one:

    http://www.myvouchercodes.co.uk/prin...ongtitle/48086
    Downloads fine in Firefox, corrupt in IE7 and IE8.

    Code:
    Code PHP:
    <?php
     
     
    class Download {
     
     
    	public $path 				= NULL;
    	public $contentType 		= NULL;
    	public $contentDisposition 	= NULL;
     
     
    	function __construct($local, $remote, $filename) {
    		$this->path 				= $local;
    		$this->remotePath			= $remote;
    		$this->filename				= $filename;
    		$this->contentType 			= my_mime_content_type($local);#$contentType;
    		$this->contentDisposition 	= 'attachment';#$contentDisposition;
    		#$this->theFile				= getimagesize($this->path);
    		#$this->contentType			= $this->theFile['mime'];
    	}
     
     
    	public function Exists() {
     
    		if (file_exists($this->path)) { 
    			return true;
    		} else {
    			return false;
    		}
    	}
     
     
    	public function Size() {
     
    		if ($this->Exists()) {
    			return filesize($this->path);
    		} else {
    			return false;
    		}
    	}
     
     
    	public function Permit_Other() {
    		return substr(decoct(fileperms($this->path)), -1);
    	}
     
     
    	public function Init() {
     
    		if ($this->Exists() && $this->Permit_Other() >= 4) {
     
    			if (stristr($this->contentType, 'image')) {
    				echo '<img src="'.$this->remotePath.'" alt="" title="" />';
    				exit();
    			} else {
    				ob_start();
    				header("Cache-Control: public, must-revalidate");
    				header("Pragma: no-cache");
    				header("Content-Description: File Transfer");
    				header('Last-Modified: '.date('r'));
    				header('Content-Type: '.$this->contentType);
    				header('Content-Disposition: '.$this->contentDisposition.'; filename="'.$this->filename.'"');
    				header("Content-Transfer-Encoding: binary");
    				header("Content-Length: ".$this->Size());
    				readfile($this->path);
    				ob_flush();
    				exit();
    			}
    		} else { 
    			return false;
    		}
    	}
     
     
    }
     
     
    ?>
     
     
    				$local = _LOCAL_PUBLIC."vouchers/$code->URL_printable";
    				$remote = _PUBLIC."/vouchers/$code->URL_printable";
    				$downloadfile = new Download($local, $remote, $code->URL_printable);
    				$downloadfile->Init();
    				exit();

    Any help greatly appreciated

  2. #2
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bump for help

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What happens if you skip php and let the webserver serve the file? Do you still have the problem with that specific file?

  4. #4
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Different http headers are served between your php script and letting apache serve the file. You could see if altering the headers has any affect.

  6. #6
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    319
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which headers?

  7. #7
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's plenty of free online http header viewers where you just input the url and it will show you the headers.

  8. #8
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Works for me.

    Get a copy of a packet sniffer (like Wireshark) and compare the packets between the two files and between IE and Firefox.

  9. #9
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bummer.. I wish I could help... it might be something related to the file itself and not the browsers.
    Nelson Amaya
    Computer Administrator
    Track It


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
  •