0

Hi i am trying to develop pdf and image feature using jquery, jsp and spring below is the jquery code got it in internet but i am not getting how to pass local URL to it example C:/Users/dell/Desktop/sample.pdf

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1    /DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js" type="text/javascript"></script>
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/blitzer/jquery-ui.css"
    rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(function () {
        var fileName = "Mudassar_Khan.pdf";
        $("#btnShow").click(function () {
            $("#dialog").dialog({
                modal: true,
                title: fileName,
                width: 540,
                height: 450,
                buttons: {
                    Close: function () {
                        $(this).dialog('close');
                    }
                },
                open: function () {
                    var object = "<object data=\"{FileName}\" type=\"application/pdf\" width=\"500px\" height=\"300px\">";
                    object += "If you are unable to view file, you can download from <a href=\"{FileName}\">here</a>";
                    object += " or download <a target = \"_blank\" href = \"http://get.adobe.com/reader/\">Adobe PDF Reader</a> to view the file.";
                    object += "</object>";
                    object = object.replace(/{FileName}/g, "Files/" + fileName);
                    $("#dialog").html(object);
                }
            });
        });
    });
</script>
<input id="btnShow" type="button" value="Show PDF" />
<div id="dialog" style="display: none">
</div>
</body>
</html>
  • To clarify, are you trying to find the file on the user's computer, or on the server? – napentathol Apr 08 '20 at 07:02
  • I've got a similar requirement but it seems that it's not possible, atleast without utilizing client-side libraries and/or API's. This issue stems from major security breaches this opens you upto, chrome even "blocks" feature altogether. Please see followinf artclies: https://stackoverflow.com/questions/18246053/how-can-i-create-a-link-to-a-local-file-on-a-locally-run-web-page https://stackoverflow.com/questions/46430889/how-to-open-local-file-from-browser/46430983 https://stackoverflow.com/questions/22535148/how-to-open-local-file-in-browser – Vuzi Apr 08 '20 at 07:13

0 Answers0