Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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;  
        }
share|improve this question
2  
do you have any code? –  Mike 'Pomax' Kamermans Nov 15 '13 at 22:00
 
You can easily get down votes, please enter some code,either explain this question more.. –  CRazyProgrammer Nov 15 '13 at 22:04
 
sorry added the code now. –  sa_nyc Nov 15 '13 at 23:10
 
does the alert box actually show :Users:harddisk:Downloads:clipcanvas_14348_offline.mp4, after inputting /Users/hardisk/Downloads/clipcanvas_14348_offline.mp4? that's strange. –  gengkev Nov 16 '13 at 2:47
1  
java and javascript is not same. i changed it for you! –  Sri Nov 16 '13 at 8:14
show 3 more comments

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.