How do I make a download on a web page having the files on my computer, outside of my web project? [closed]

2

I need to make a web application that the user uploads PDF files and can download them later. The upload part is done, except the files in a folder of my PC /home/william/web . To save the files to my PC, I edited the file server.xml of Apache Tomcat by adding:

<Context docBase="/home/william/web" path="/teste"/>

This is the code snippet of index.html where the user sends the files:

<p>Mande seu arquivo PDF aqui:</p>
<form action="./UploadServlet" method="post" enctype="multipart/form-data">
    <input name="arquivo" type="file">
    <input name="Enviar" type="submit">
</form>

The form with the file goes to the UploadServlet for the doPost method:

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    Part p = request.getPart("arquivo");
    p.write("/home/william/web/webbla" + p.getSubmittedFileName());
}

Now you would need to make the downloads available to the user. I made a page upload.html , there already tried to put several paths trying to access the PDF, but I can not. My project is inside the NetBeansProjects folder, which in turn is in /home/william . PDF files are in /home/william/web .

    
asked by anonymous 07.11.2015 / 22:14

0 answers