How to receive the actual location of a file

0

I upload files to a folder, which works when running in eclipse. But when I try to upload through a browser, I am not allowed to upload it because of its security.

My question is, is there any way to get the browser to return the file location? Or is there any way to send the file so you can copy it to the destination folder?

If necessary to elaborate a response I leave below my code.

//caminho relativo da pasta destino
final String Dest = System.getProperty("user.dir") + "/";

public void addMusica(String musica_nome, Part musica, String ano) throws IOException {

    String fileName = getFileName(musica);

    File data = null;

    try {

        File music = new File(fileName);

        data = new File(Dest + music.getName());

        Files.copy(music.toPath(), data.toPath());

    } catch (Exception e) {
        e.printStackTrace();
    }

}

//tratamento do path
private String getFileName(Part part) {

    final String partHeader = part.getHeader("content-disposition");

    for (String content : part.getHeader("content-disposition").split(";")) {
        if (content.trim().startsWith("filename")) {
            return content.substring(content.indexOf('=') + 1).trim().replace("\"", "");
        }
    }
}
    
asked by anonymous 06.07.2017 / 15:59

0 answers