Reputation: 137
my view 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>
my 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)
}
}
I need to get the full path of my file on my local disk for example ( c: /folder1/notes.txt ) or ( f : /folder2/note2.txt )**
Upvotes: 1
Views: 734
Reputation: 661
You will get whole path by using originalFilename
def file = request.getFile('uploadFile')
println "FileName"+file.originalFilename
Output:
FileName C:\Users\BRACT-Admin\Downloads\vit.mp4
Upvotes: 0
Reputation: 24776
In accordance with the HTML specification only the name of the file is sent, not the entire path. Doing so would pose a leak of potentially sensitive or personally identifiable information.
If you need the full path you will have to have your users enter that manually as a separate piece of data. the file
input won't give you this information, no matter what you do.
Upvotes: 1