PDA

View Full Version : Saki - File upload - Doesn't give an absolute path of a file in FF



amodg
22 Dec 2009, 7:11 AM
Hi,

I am using a (saki) component for file uploading. However,

,getFilePath:function(inp) {
alert(inp.getValue());
return inp.getValue().replace(/[^\/\\]+$/,'');

} // eo function getFilePath

this 'inp' doesn't give me an absolute path of a file in Firefox. It works perfectly fine in IE.

Can I get some input on this?

Thanks in advance,
-Amod

realjax
22 Dec 2009, 7:22 AM
If this is the path from the file on the clients side then FF won't serve it to you..

VinylFox
22 Dec 2009, 8:47 AM
...this 'inp' doesn't give me an absolute path of a file in Firefox. It works perfectly fine in IE...

This is a security thing. It's on purpose, and controlled completely by the browser.

amodg
22 Dec 2009, 9:14 PM
But, when you upload any file, you have to have an absolute path so that we can read those files to upload it. In IE, it gives you a complete path like "C:/My Dcouments/text.txt" and you are all set to read the file from this location. However in Firefox, it gives a path "text.txt" and you have no clue where to read it from...8-|

Thanks,
-Amod

realjax
22 Dec 2009, 11:47 PM
You can't read the file from the clients path. That is not how things work. The browser sends you the file, ie text.txt and it's local path is of no use to you nor any of your business..

Internet explorer's 'feature' to send the path is, IMO indeed a possible security risk, IE should not send it either.

In short: forget about that path. Totally.

However....
If you for whatever reason want the user to select a file, and use that selection to upload a file in another part of your app the solution is then to copy the (text)contents of the selection box by using the onblur event or something. That might work.

Animal
23 Dec 2009, 12:22 AM
IE6 is seriously buggy in the way it sends the full path too.

It includes backslashes in the file name (because they are Windows' directory separators). But the MIME standards indicate that backslashes quote the following character, so if you use standards compliant code (ie the Java Mail API) to parse the upload packet, then "C:\foo\bar\bletch.txt" is reported as named "foobarbletch.txt".

I've worked with the Java Mail authors recently to introduce a workaround for this.

amodg
23 Dec 2009, 2:10 AM
Hello,

Thanks for your response. Can i get some input as how to read the files in java?
Can I just use request.getInputStream() to get the file input streams?

Thanks,
-Amod

Animal
23 Dec 2009, 2:41 AM
You could. Then you would have to read up on the MIME multipart message format, and parse the post data yourself.

But you'd probably be better off using the Java Mail API (Assuming it's got that fix in)

http://java.sun.com/products/javamail/

amodg
23 Dec 2009, 2:42 AM
I mean, can I get some input on the backend end code in java, in order to upload the files using saki?

Animal
23 Dec 2009, 3:08 AM
Colourless green ideas sleep furiously.

amodg
23 Dec 2009, 3:35 AM
Hi Animal,

Is there anyway that I can set the content type as 'multipart' form data while sending the files using saki? On the server side, I'm getting the content type as 'application/x-www-form-urlencoded' in which the request body looks like

'param1=foo&param2=bar'.

So, it's not the way to get the multipart form data.

Thanks
-Amod

bmsshree
2 Apr 2010, 9:16 PM
But, when you upload any file, you have to have an absolute path so that we can read those files to upload it. In IE, it gives you a complete path like "C:/My Dcouments/text.txt" and you are all set to read the file from this location. However in Firefox, it gives a path "text.txt" and you have no clue where to read it from...8-|

Thanks,
-Amod


Hi,

Have you got any solution for the problem?
I have also stuck up in the same!
Please forward the solution, if you have it.

Thanks,
-Bhagyashree

amodg
4 Apr 2010, 9:02 PM
Hello,

It works. Make sure that the form is having a array of formfiles and it is getting submitted. The problem arises when a form is not getting submitted.

I hope this helps.

Thanks,
-Amod