It is necessary to give files to users for downloading without shining a direct path.

Now everything works like this:

<? $urll = $arResult["arUser"]["LOGIN"]; $utllx = $urll . ".xlsx"; ?> <a href='<?echo $utllx?>'>Π‘ΠΊΠ°Ρ‡Π°Ρ‚ΡŒ excel Ρ„Π°ΠΉΠ»</a> 

But so the file path is visible. Please tell me how to hide the path.

    1 answer 1

     $name = './img/ok.png'; $fp = fopen($name, 'rb'); // отправляСм Π½ΡƒΠΆΠ½Ρ‹Π΅ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠΈ header("Content-Type: image/png"); header("Content-Length: " . filesize($name)); // скидываСм ΠΊΠ°Ρ€Ρ‚ΠΈΠ½ΠΊΡƒ ΠΈ останавливаСм Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ скрипта fpassthru($fp); exit; 

    Link to manual, example from the same http://php.net/manual/ru/function.fpassthru.php

    More useful headlines: Content-Disposition , Content-Length

    As a rule, with this approach, a temporary link to the file is created, stored in the database. The link consists of a hash and file path. Hash is shown to the user, the path is not shown. As soon as the user has downloaded the file - mark the link used or simply delete it from the database.

    • Made. A huge bunch of something like a PK! Λ£ [Content_Types] .xml ( U N 0 # - Zhelez
    • four
      Better yet, use XSendFile for Apache or X-Accel-Redirect for nginx. I advise you to read about these options. PHP is not directly involved in the transfer of the file, which reduces the load on the server and allows you to give files of any size. - ilyaplot
    • one
      header("Content-Type: image/png"); stayed? for xml this should be header("Content-Type: text/xml"); - cache
    • @ilyaplot, special thanks for X-Accel-Redirect. - cache