Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript上传文件的完整路径_Java_Javascript_Eclipse_File Upload - Fatal编程技术网

使用javascript上传文件的完整路径

使用javascript上传文件的完整路径,java,javascript,eclipse,file-upload,Java,Javascript,Eclipse,File Upload,嗨,我想要用户输入的文件路径。我在网上读到了很多问题,我的问题不是关于从文件上传获得完整路径。我已经知道这是不可能的,根据浏览器的安全设置,我只能得到文件名,而不是整个文件路径。所以我请求用户输入完整路径,但问题是现在当我读取路径时,“/”被替换为“:” 例: 输入 更改为 :Users:harddisk:Downloads:clipcanvas_14348_offline.mp4 请帮忙 我在这里附上代码 <input type="file" id="file" name="file"

嗨,我想要用户输入的文件路径。我在网上读到了很多问题,我的问题不是关于从文件上传获得完整路径。我已经知道这是不可能的,根据浏览器的安全设置,我只能得到文件名,而不是整个文件路径。所以我请求用户输入完整路径,但问题是现在当我读取路径时,“/”被替换为“:”

例:

输入

更改为

:Users:harddisk:Downloads:clipcanvas_14348_offline.mp4
请帮忙

我在这里附上代码

<input type="file" id="file" name="file"/> 

function upload_video()
        {
            filename=document.getElementById("file").value;
            alert("uploading"+filename);
            window.location.href="VideoUpload?file="+filename;  
        }

函数上传_视频()
{
filename=document.getElementById(“文件”).value;
警报(“上传”+文件名);
window.location.href=“VideoUpload”file=“+文件名;
}

我自己解决了。这不是一个很好的解决方案,只是一个变通办法

对于文件名,我还要求用户输入文件路径,然后将两者合并并存储

下面是它的代码:

<form action="VideoUpload" method="get" id="upload_form">
                <input type="file" id="file" name="file"/> 
                <input type="text" id="path" name="path"/> 
                <input type="submit" value="Upload" name="submit"/>
            </form>


String name=request.getParameter("file");
        String path=request.getParameter("path");
        String filename=path+name;

字符串名称=request.getParameter(“文件”);
字符串路径=request.getParameter(“路径”);
字符串文件名=路径+名称;

在我找到更好的解决方案之前,这是一个变通办法

你有任何代码吗?你可以很容易地获得投票,请输入一些代码,或者进一步解释这个问题。抱歉,现在添加了代码。警告框是否实际显示
:用户:硬盘:下载:clipcanvas_14348_offline.mp4
,输入
/Users/hardisk/Downloads/clipcanvas_14348_offline.mp4
?这很奇怪。java和javascript不一样。我给你换的!
<form action="VideoUpload" method="get" id="upload_form">
                <input type="file" id="file" name="file"/> 
                <input type="text" id="path" name="path"/> 
                <input type="submit" value="Upload" name="submit"/>
            </form>


String name=request.getParameter("file");
        String path=request.getParameter("path");
        String filename=path+name;