gpt4 book ai didi

file - 获取我要上传的文件的路径

转载 作者:行者123 更新时间:2023-12-02 14:40:47 26 4
gpt4 key购买 nike

我的看法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>

我的 Controller Uploadfullpath
 package library

class UploadfullpathController {

def index() { }

def fullpath(){

def files = request.getFile('file')
def fullpath=files.getProperties()
System.out.println("full path is : "+ fullpath)
}
}

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

最佳答案

根据HTML规范,仅发送文件名,而不发送整个路径。这样做可能会泄漏潜在的敏感或个人身份信息。

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

关于file - 获取我要上传的文件的路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36582174/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com