The code sample below can be places in a Servlet to create a File object of the path supplied by the HTML caller form.

Java Code:
PrintWriter out = res.getWriter();
String selectedImg = req.getParameter("imagepath");
File file = new File (selectedImg);
out.println("File size is :" + file.length());