How to show popup for save or view the file? I am displaying file names as links on the page, when I click on particular link, it should ask the user that, save file or view file something like below image. 

In my case this popup is not coming, directly the file content is displaying on browser. So how can I achieve this. Thanks for your any suggestions.

My code to display dynamic links as follow: 

$uri = 'public://'; 
  $path= file_create_url($uri);

$data .= '&lt;div class = "public-file-names"&gt;&lt;a href="'.$path . $foldnames .'/'. $filenames.'"&gt;' ."--". $filenames .'&lt;/a&gt;&lt;br&gt;&lt;/div&gt;';
The browser you are using recognise the linked document format and try to show it directly. It is mainly true with images and PDF files.

If you want to force the browser to download the file (or to open it with a local application), as explain in this answer, you can use the HTML5 download attribute.

$uri = 'public://'; 
$path= file_create_url($uri);

$data .= '&lt;div class = "public-file-names"&gt;&lt;a href="'.$path . $foldnames .'/'. $filenames.'" download&gt;' ."--". $filenames .'&lt;/a&gt;&lt;br&gt;&lt;/div&gt;';