PDA

View Full Version : File uploading using ext js and basic java



notsobright
2 Dec 2014, 10:47 AM
Hi all,
Pardon my lack of front end experience, if what I ask is stupid.

I have gone through many of the fileuploadfield examples or threads about it, but still can't get my screen working.

Here is my scenario:
I am trying to get a screen which provides the user a browse button to select a file, and select a string field on the screen. User then hits submit.

Upon submitting the form, the file should be uploaded to the server and specific actions need to be taken based on the string they select.

So far - I have used the fileUploadField on the screen.

I got the text field and the browse button. I have the drop down. The values in the drop down are populated from a table in the backend.
Upon clicking Submit button - I also see that the file path and the string are both being sent to my file parser class I have written. (I send the filepath and the string as parameters).

My concern:
1) When I pass in the filepath through the browser to the resource and to my parser, my parser throws a filenotfound exception saying it can't find the file. But when I write a small main method and pass the exact same name, it parses the file and persists it in the database.

I am using the fileUploadField that ships with ext-js
When I select the file using the browse button : The file path comes in with backslashes - I have a feeling this is the issue:
C:\Users\username\facePath.csv

I have tried replacing the \\ with /. Still no use.

I wonder if someone else has experienced this issue and have a solution.

Here is the exception I keep getting:



java.io.FileNotFoundException: filePath=C%3A%5CUsers%5Cfake_file.CSV
(The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at java.io.FileInputStream.<init>(FileInputStream.java:79)
at java.io.FileReader.<init>(FileReader.java:41)

mitchellsimoens
4 Dec 2014, 3:34 AM
The error has filePath=C%3A%5CUsers%5Cfake_file.CSV in it, is this due to the encoding of the slashes? What is displayed in the file field shouldn't matter as when you submit the form the file will be uploaded to the server and the server would have to deal with how it's writing that to disk.