I'm having an issue with my ajax function returning "Cannot modify header information - headers already sent"
Here is my code:
$result = array();
function listFolderFiles($dir){
$ffs = scandir($dir);
foreach ( $ffs as $ff ){
if ( $ff != '.' && $ff != '..'){
if ( strlen($ff)>=5 ) {
if ( substr($ff, -4) == '.jpg' || substr($ff, -4) == '.png' || substr($ff, -4) == '.jpeg' ) {
$timestamp = explode('/',$dir);
$obj['name'] = ''.$timestamp[8].'/'.$ff;
$obj['size'] = filesize($dir.'/'.$ff);
$result[] = $obj;
}
}
if( is_dir($dir.'/'.$ff) )
listFolderFiles($dir.'/'.$ff);
}
}
if(!empty($result)) {
header('Content-type: text/json');
header('Content-type: application/json');
echo json_encode($result);
} else {
die;
}
}
$files = array();
$files = listFolderFiles($fullUploadDir);
Does anybody have any ideas as to how I may solve this issue?
Thanks, Codarz360