Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.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
File 获取要在grails中上载的文件的路径_File_Grails_Gsp_Grails 2.4 - Fatal编程技术网

File 获取要在grails中上载的文件的路径

File 获取要在grails中上载的文件的路径,file,grails,gsp,grails-2.4,File,Grails,Gsp,Grails 2.4,我的观点gsp index.gsp <head> <meta name="layout" content="main"> <title>Upload file and fullpath</title> </head> <div id="upload-data" class="content scaffold-create" role="main"> <div class="content scaffold-create

我的观点gsp index.gsp

<head>
<meta name="layout" content="main">
<title>Upload file and fullpath</title>
</head>
<div id="upload-data" class="content scaffold-create" role="main">
<div class="content scaffold-create" role="main">
    <h1>Upload file and full path</h1>
    <g:if test="${flash.message}"><div class="message" role="status">${flash.message}</div></g:if>
    <g:uploadForm action="fullpath">
        <fieldset class="form">
            <input type="file" name="file"  />
        </fieldset>
        <fieldset class="buttons">
            <g:submitButton name="Upload" value="Upload" />
        </fieldset>
    </g:uploadForm>
</div>

我需要在本地磁盘上获取文件的完整路径,例如(c:/folder1/notes.txt)或(f:/folder2/note2.txt)**

根据HTML规范,只发送文件名,不发送整个路径。这样做会造成潜在敏感或个人身份信息的泄露


如果您需要完整的路径,您必须让您的用户作为单独的数据段手动输入该路径。无论您做什么,
文件
输入都不会提供此信息。

您将使用originalFilename获得整个路径

def file = request.getFile('uploadFile')

println "FileName"+file.originalFilename
输出:

FileName C:\Users\BRACT-Admin\Downloads\vit.mp4

根据HTML规范,不包括路径。只有文件名。谢谢回答。我需要获取文件的完整路径。您不能使用文件输入。如果需要,用户必须单独键入。
FileName C:\Users\BRACT-Admin\Downloads\vit.mp4