2016-05-30 4 views
1

私はpdfを開くボタンを作成したいと思います。このpdfは別のフォルダにありますが、このフォルダにはアクセスできません。誰かが私を助けることができます、私はこれについて全く新しいです。ここでYii2フォルダへのURLのURL

は私のボタンです:

$button = Html::a('Geef document weer', ['/uploads/documenten/' . $model->documents[0]->location . '/' . $model->documents[0]->file . $model->documents[0]->format], ['class' => 'btn btn-primary btn-xs', 'target' => '_blank']); 
+0

あなたはpdfをダウンロードしたいですか? – jithin

答えて

0

ハッシュ記法を使用しますが、リンクを指定しないでください、HTMLヘルパーを使用しなくてもと「yourPath」内のリンクを書くには

適切な値を設定します
$button = Html::a('Geef document weer', 
'yourPath/uploads/documenten/' . $model->documents[0]->location . '/' . $model->documents[0]->file . $model->documents[0]->format, 
['class' => 'btn btn-primary btn-xs', 'target' => '_blank']); 

または使用@webエイリアス

$button = Html::a('Geef document weer', 
    Url::to('@web/uploads/documenten/') . $model->documents[0]->location . '/' . $model->documents[0]->file . $model->documents[0]->format, 
['class' => 'btn btn-primary btn-xs', 'target' => '_blank']); 
+0

ありがとう@scaisEdge、これはまさに私が探していたものです:) –

関連する問題