要做到这一点,我改变的index.php到窗体:
echo '<form method="post" action="download.php"><div id="divexport">';
echo '<input type="hidden" name="Export" value="coverLetter">';
echo '<input type="submit" id="Export" value="Cover Letter" />';
echo '</div></form>';
,然后添加的头信息的download.php,只是fpassthru之前
// Create blob REST proxy.
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
$blobfile = "myblob.pdf";
$filename = basename($blobfile);
$ext = new SplFileInfo($filename);
$fileext = strtolower($ext->getExtension());
try {
// Get blob.
$blob = $blobRestProxy->getBlob("document", $blobfile);
if($fileext === "pdf") {
header('Content-type: application/pdf');
} else if ($fileext === "doc") {
header('Content-type: application/msword');
} else if ($fileext === "docx") {
header('Content-type: application/vnd.openxmlformats-officedocument.wordprocessingml.document');
} else if($fileext === "txt") {
header('Content-type: plain/text');
}
header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
fpassthru($blob->getContentStream());
}
catch(ServiceException $e){
// Handle exception based on error codes and messages.
// Error codes and messages are here:
// http://msdn.microsoft.com/en-us/library/windowsazure/dd179439.aspx
$code = $e->getCode();
$error_message = $e->getMessage();
echo $code.": ".$error_message."<br />";
}