Hi I want file path from the user input. I read multiple questions online mine isn't about getting full path from file upload. I already know it is not possible, according to browser security settings I can only get filename and not the whole filepath. So I request the user to enter the full path , but problem is now when I read the path the '/' get substituted for ':'
Ex :
Input
/Users/hardisk/Downloads/clipcanvas_14348_offline.mp4
changes to
:Users:harddisk:Downloads:clipcanvas_14348_offline.mp4
Please help.
I am attaching the code here
<input type="file" id="file" name="file"/>
function upload_video()
{
filename=document.getElementById("file").value;
alert("uploading"+filename);
window.location.href="VideoUpload?file="+filename;
}
Well I solved it by myself. Not a great solution just a workaround.
With the filename am also asking the user to enter file path and then combining the two and storing.
Here's code for it:
<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;
It is a workaround till I find a better solution.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.