0
「我已上載於服務器上的文件,我想在我的網站用戶下載此文件,他應該是一個水印的文件(水印文本將在PDF文件中‘他的電子郵件ID’ )「運行時間水印PDF文件Yii框架生成
控制器:
public function actionDownloadFiles()
{
ignore_user_abort(true);
$path = (Yii::app()->basePath.'/../images/prequlification_form/'.$_GET['path']);
$fullPath = $path ;
if ($fd = fopen ($fullPath, "r")) {
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
header("Content-type: application/octet-stream");
header("Content-Disposition: filename=\"".$path_parts["basename"]."\"");
header("Content-length: $fsize");
header("Cache-control: private");
while(!feof($fd)) {
$buffer = fread($fd, 2048);
echo $buffer;
}
}
fclose ($fd);
exit;
}
查看:
<h3><p class="note"><span class="required">form</span> Filling is required.</p></h3>
<?php echo $form->errorSummary($model); ?>
<!--here is the user id-->
<?php //echo $id;?>
<div class="file-dwnload">
<?php
$data=prequalificationForm::model()->findByPk(1);
if(!empty($data)) {
echo '<div class="dwnload-file"><li>'.
CHtml::link($data->file_path,array("prequalificationForm/downloadFiles","path"=>($data->file_path))).
'</li></div> <div class="dwnload-butn"><li>'.
CHtml::link('Download File',array("prequalificationForm/downloadFiles","path"=>($data->file_path)))
."</li></div> " ;
}?></div>
<div class="row">
<?php echo $form->labelEx($model,'file_path'); ?>
<?php echo $form->fileField($model,'file_path',array('size'=>60,'maxlength'=>255)); ?>
<?php echo $form->error($model,'file_path'); ?>
</div>
<div class="row buttons">
<?php //echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
<?php echo CHtml::submitButton($model->isNewRecord ? 'Submit' : 'Save',array('class'=>'submit-btn')); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
所以什麼不順心的,什麼是錯誤? –
沒有什麼是錯了,我只是想知道這是怎麼可能 –
這裏是解決方案 –