Skip to content
Advertisement

How can I get the URL of a file on the users’ computer when using ?

I’m a college student and I’m currently working on a video library in JSP. I’m working on the part where the user inserts their videos, for this I need to save the URL of the video, the path, in the code the, <input type=file>, but when the user would insert a file, I can’t get the URL at all, only the name of the file. I know that for security reasons, the browser can’t access the users’ files, but I’d like to save the URL in the database, not just the file name and type. Is there a work-around to this whole thing?

This is my code for the insert video Java Server Page:

            <form method="post" action =<%= string1 %>>
                    <h1>Insira o vídeo</h1>

                    <p>
                        <label>Nome do vídeo</label> <input
                            id="nome_vid" name="vid_nome" required="required"
                            type="text" placeholder="Vídeo fixolas" />
                    </p>

                    <p>
                        <label>Vídeo</label><input id="btnExplore" name="btn_file" type="file"  />
                    </p>
                    <p>
                        <label>Thumbnail</label><input id="btnExplore2" name="btn_file2" type="file"  />
                    </p>
                    <p>
                        <input type="submit" value="Inserir" name="submeter" onclick = "validalogin()"/>
                    </p>    
                    <p class="link">
                    
                        <a href=<%= string2 %>>Principal</a>  
                        </a>
                    </p>    
    </form>

Advertisement

Answer

You can create a folder to save those files in your project folder, so it will not facing security issues. The other way is you hardcoded the front URL + filenames. For example, “C:Documents” + filenames as you can get the filename.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement