S
S
Satir012015-04-19 10:41:23
1C-Bitrix
Satir01, 2015-04-19 10:41:23

Bitrix download link not working?

Good afternoon!
I'm trying to create an infoblock in Bitrix that gives a link to download the file.
I use this design

<?$pdf = CFile::GetPath($arResult['PROPERTIES']['PDF']['VALUE']);?> 

<a href="<?=$pdf;?>" class="file-types-link" download>pdf</a>

The infoblock contains a property with a PDF code.
Hovering over a link shows the wrong URL. And it offers to save the file with the name "domain.html"
What could be the matter, what am I doing wrong?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Express777, 2015-04-19
@Express777

First, check that you have a file ID passed in $arResult['PROPERTIES']['PDF']['VALUE'] .
If everything is fine and an integer is transmitted (for example, "33", etc.), then try this:

<?$pdf = CFile::GetFileArray($arResult['PROPERTIES']['PDF']['VALUE']);?> 

<a href="<?=$pdf["SRC"];?>" class="file-types-link" download>pdf</a>

A
artur43211, 2015-05-07
@artur43211

You must first check what $arResult['PROPERTIES']['PDF']['VALUE'] contains.

<?if(IntVal($arResult['PROPERTIES']['PDF']['VALUE']) > 0):
$pdf = CFile::GetPath($arResult['PROPERTIES']['PDF']['VALUE']);?> 
<a href="<?=$pdf;?>" class="file-types-link" download>pdf</a>
<?endif;?>

If the news.list or news.detail component is used, then check whether at least one property is selected in the component's output settings.

N
Naxangel, 2015-06-26
@Naxangel

I'm not strong in PHP, but in my opinion I need to tell him to show the variable.
Just did this, it works.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question