PHP Download Image don't appear

Hi guyz, I have been figuring out what is wrong with my code why image doesn’t appear when I download it.
Heres is my code:
[php]<?php
require_once(‘include/middletier/waitlist_form.class.php’);
$tbleswaitlist = new waitlist_form();
$tbleswaitlist->display_upg($_REQUEST[‘studentNum’]);

 $cpath="C:xampp/htdocs/OCWMS/modules/waitlist/uploads/".$tbleswaitlist->name;
 header("Pragma: public");
 header("Expires: 0");
 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
 header("Cache-Control: private",false);
 header("Content-type: ".$tbleswaitlist->fileType);                
 
 header("Content-Disposition: attachment; filename=\"".basename($tbleswaitlist->name)."\"" );
 header("Content-Length: ". $tbleswaitlist->fileSize); 
 ob_clean();
 flush();
 readfile($cpath);
 exit();

?>[/php]
Hope you help me…thanx

Your path is missing a slash:

[php]C:xampp/htdocs/OCWMS/modules/waitlist/uploads/[/php]

Should be:

[php]C:/xampp/htdocs/OCWMS/modules/waitlist/uploads/[/php]

Also, check that the image you’re trying to output exists. You could echo the $cpath variable then check it manually:

[php]echo $cpath;[/php]

Or even check with PHP:

[php]if(!file_exists($cpath)) { die ‘Image not found!’; }[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service