CodeIgniter Forums
Force download shows a blank page! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Force download shows a blank page! (/showthread.php?tid=1107)



Force download shows a blank page! - behnampmdg3 - 02-12-2015

Hi;

Not sure why forcedownload shows a blank page Sad

PHP Code:
$image='http://members.getaltitude.com/wp-content/uploads/2015/01/GETALTITUDE_black-300x64.png';
 if(@
getimagesize($image))
 {
 
$data file_get_contents($image);
 
force_download($file_name$data);
 }
 else
 {
 echo 
"The QR file does not exist!";
 } 

Here is the whole code:

PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class 
Download_qr extends CI_Controller {
 
 
 
public function force($qrcode)
 {
 
$this->load->helper('download');
 
$this->load->model('model_auth');
 
$query $this->db->get_where('url_tokens', array('short_url' => $qrcode));
 foreach (
$query->result() as $row)
 {
 
$product_id $row->product_id;
 
$product_type $row->product_type;
 if(
$product_type=='profile')
 {
 
$product_type_directory "profile";
 
$product_query 'card_details_id';
 }
 if(
$product_type=='campaign')
 {
 
$product_type_directory "campaigns";
 
$product_query 'campaign_details_id';
 }
 }
 
$data['item_details'] = $this->model_auth->$product_query($product_id$this->session->userdata['logged_data']['member_id']);
 if(
$product_type=='profile')
 {
 
$file_name $data['item_details'][0]->first_name."-".$data['item_details'][0]->last_name."-".$qrcode.".png";
 }
 if(
$product_type=='campaign')
 {
 
$file_name $data['item_details'][0]->name;
 } 
 if(
count($data['item_details'])>0)
 {
 
$image='http://members.getaltitude.com/wp-content/uploads/2015/01/GETALTITUDE_black-300x64.png';
 if(@
getimagesize($image))
 {
 
$data file_get_contents($image);
 
force_download($file_name$data);
 }
 else
 {
 echo 
"The QR file does not exist!";
 }
 }
 }


What am I doing wrong?


RE: Force download shows a blank page! - behnampmdg3 - 02-12-2015

Anyone?


RE: Force download shows a blank page! - mwhitney - 02-13-2015

A blank page often indicates a PHP error which has been suppressed. This means you need to check your error logs and/or enable the error messages to determine where the error has occurred.

The best assumption I can make from your code is that file_get_contents() is throwing an error.


RE: Force download shows a blank page! - includebeer - 02-15-2015

force_download just set the headers to download a file, it doesn't output anything on the web page.


RE: Force download shows a blank page! - behnampmdg3 - 02-15-2015

Hi;

Errors, notices and all other warning types are. This is very strange. It used to pop up the browsers download panel (asking where to download to)!


RE: Force download shows a blank page! - Narf - 02-16-2015

(02-15-2015, 11:43 PM)behnampmdg3 Wrote: Hi;

Errors, notices and all other warning types are. This is very strange. It used to pop up the browsers download panel (asking where to download to)!

The errors and warnings are there to tell why why it's not working ... don't ignore them.


RE: Force download shows a blank page! - behnampmdg3 - 02-16-2015

(02-16-2015, 01:59 AM)Narf Wrote:
(02-15-2015, 11:43 PM)behnampmdg3 Wrote: Hi;

Errors, notices and all other warning types are. This is very strange. It used to pop up the browsers download panel (asking where to download to)!

The errors and warnings are there to tell why why it's not working ... don't ignore them.
hey Narf;

It's a blank page. Shows nothing Sad


RE: Force download shows a blank page! - includebeer - 02-16-2015

(02-16-2015, 02:45 AM)behnampmdg3 Wrote: hey Narf;

It's a blank page. Shows nothing Sad

So where are those "errors, notices and all other warning" ?