Link to home
Start Free TrialLog in
Avatar of seopher
seopher

asked on

RSS Enclosures in PHP

Trying to obtain the <enclosure> details for a podcasting page...  I've got the content displaying properly but I need to access the content inside the enclosure.

Outputting the item gives:

[enclosure] => Array
        (
            [url] => http://website/directory/name.mp3
            [length] => 4,374,069
            [type] => audio/mp3
        )

So I've got a "download this podcast" link but I can't get the [url] element from the enclosure... what is the syntax for doing this?  Because it sure as butters isn't $item[url]

Offering 500 points because it's important!
Avatar of Aamir Saeed
Aamir Saeed
Flag of Pakistan image

Please try this function,

function downloadfile($file,$ctype){
      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: $ctype;");                  
      header('Content-Disposition: attachment; filename='.basename($file).';');
      header("Content-Length: ".filesize($file).";");
      readfile($file);
}
ASKER CERTIFIED SOLUTION
Avatar of OliWarner
OliWarner

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of seopher
seopher

ASKER

Ugh, thanks I was being rather dumb, that's done the trick perfectly.

Nice work.