Upload file without "Browse"
I'm planning to write a web application (.net probably) that will need to analyze images found on users local machine.
The trivial solution would be letting the user browse and select the file to be uploaded.
I want to automate this process as possible and since I should know the exact location of the image file on the local disk (I'm al开发者_StackOverflow社区so writing the client side), I would like to add a simple button that when clicked (web side), it will retrieve the file to the server (upload).
I know this is a major security issue, and this option is always deleted, but I thought there might be a possibility to have such an option with a signed Java applet or Flash.
Any idea ? (Java is preferable). I don't mind letting the user install something, since the users will need to install the client side as well.
It's not clear what your question is. Are you asking if you can do what you describe with a signed Java applet? Yes, you can.
You can use something like this to read in a file.
File inputFile = (File) AccessController.doPrivileged(new PrivilegedAction() {
public Object run()
{
File inputFile1 = new File("C:\\Program Files\\MyFolder\\MyFile.jpg");
return inputFile1;
}
});
FileReader in = new FileReader(inputFile);
if you want to use a variable and not static text as the file location you have to use a final variable like this.
final String myfilename = <path or string var of filename>
File inputFile = (File) AccessController.doPrivileged(new PrivilegedAction() {
public Object run()
{
File inputFile1 = new File(myfilename);
精彩评论