0
嗨,我需要創建文件下載。下載和表單驗證和dB插入的填寫表單都在同一頁面中。如果表單被提交,則需要使用另存爲窗口自動觸發文件下載。我寫的代碼爲:顯示一些文字後在php下載文件
if(isset($_POST['submit'])){
$u=$_POST['uname'];
/*similarly getting all posted data*/
echo '<br><b>'.JText::_('Thank you for submitting your details...').'</b>';
$db =& JFactory::getDBO();
$query = "/*db inserting query*/";
$db->setQuery($query);
$db->query();
$filee= basename($path); /*$path contains value form $_POST*/
$full='http://localhost/joomla/images/uploads/'.$filee;
?>
<br><b>
<span>If the download does not start automatically in a few seconds, <a href="<?php echo JURI::base(); ?>/images/myfile/<?php echo $filee;?>" target="_blank"><b> Click this link</b></a></span></b>
<?php
header('Content-Description:File Transfer');
header("Content-type:application/pdf");
header("Content-type:application/zip");
header("Content-type:image/jpeg");
header("Content-type:image/png");
header("Content-type:application/msword");
header("Content-Disposition: attachment; filename=".$filee."");
header("Cache-control: private");
readfile($full);
}
else{ code for printing fill up form}
我需要打印的「感謝提交..」 ..等消息之前downloading.but現在,當我提交填寫表格的下載與顯示出上面的文字開始。等待一段時間後我應該怎麼做下載?
使用'睡眠();'等待一段 –