如何获取filepath而不是url

时间:2012-01-02 22:02:54

标签: javascript file href src

我想制作一个javascript文件上传器。此上传器的css位置是“〜/ Scripts / fileuploader / fileuploader.css”,js位置是“〜/ Scripts / fileuploader / fileuploader.js”。我想做以下事情:

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="~/Scripts/fileuploader/fileuploader.css" rel="stylesheet" type="text/css">
</head>
<body>      
    <div id="demo"></div>
    <ul id="separate-list"></ul>

    <script src="~/Scripts/fileuploader/fileuploader.js" type="text/javascript"></script>
    <script>
        function createUploader() {
            var uploader = new qq.FileUploader({
                element: document.getElementById('demo'),
                listElement: document.getElementById('separate-list'),
                action: '~/Scripts/fileuploader/do-nothing.htm'
            });
        }
        window.onload = createUploader;     
    </script>    
</body>
</html>

但是,<link href="~/Scripts/fileuploader/fileuploader.css"<script src="~/Scripts/fileuploader/fileuploader.js"成为http://localhost:1304/Administration/blue/en-gb/Entity/Index/~/Scripts/fileuploader/fileuploader.js?_=1325540158292http://localhost:1304/Administration/blue/en-gb/Entity/Index/~/Scripts/fileuploader/fileuploader.js

如何更改此内容以使其~/Scripts/fileuploader/fileuploader.js而不是http://localhost:1304/Administration/blue/en-gb/Entity/Index/~/Scripts/fileuploader/fileuploader.js

1 个答案:

答案 0 :(得分:0)

为什么你需要把那个〜符号放到那里?如果您的html文件(或我不知道的php)位于您使用该符号的位置,删除〜/符号将解决问题。

<link href="Scripts/fileuploader/fileuploader.css" rel="stylesheet" type="text/css">

<script src="Scripts/fileuploader/fileuploader.js" type="text/javascript"></script>