getAttachment($id); //headers header("Content-Type: $attachment->contentType"); header("Content-Disposition: attachment; filename=$attachment->filename"); //output the body echo $attachment->data; ?>