469,603 Members | 2,049 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,603 developers. It's quick & easy.

get the full file path of file input field

Hello All,

I have a input box on the HTML page with the type set to file. What I
want is that when the value changes in the file textbox, it should give
me the full file path. I have even tried passing the value to a hidden
control but all it does is passes only the File Name and not the file
path.

How do I go about it. I tried checking GMAIL service (Compose Mail) but
all I could get is that they are passing the window and the file object
to a function, the code of which is not accessible.

Any help will be greatly valuable.

Regards,

Vibhu Bansal.

Jul 7 '06 #1
3 6744
Hi Vibhu

what you're trying to do probably not allowed because of security
restrictions of the browser sandbox. If the browser or web page were
given access to the contents or filepaths of the client machine it
could used maliciously. You don't need to know the filepath to send the
file to the server - the browser will attach and send the file to the
form data.

regards,
-ad
Vibhu wrote:
Hello All,

I have a input box on the HTML page with the type set to file. What I
want is that when the value changes in the file textbox, it should give
me the full file path. I have even tried passing the value to a hidden
control but all it does is passes only the File Name and not the file
path.

How do I go about it. I tried checking GMAIL service (Compose Mail) but
all I could get is that they are passing the window and the file object
to a function, the code of which is not accessible.

Any help will be greatly valuable.

Regards,

Vibhu Bansal.
Jul 7 '06 #2
Hi,

The reason why I want the full path of the file is that I want the file
to be uploaded in the background while the user is still on the
webpage; just the way GMAIL is attching files. I am sure using AJAX
this can be achieved.

So what I want is that the GET method of the .html page is invoked in
the background that will upload the file from the client to the server.

Hope this helps.

Regards,

Vibhu Bansal.
admataz wrote:
Hi Vibhu

what you're trying to do probably not allowed because of security
restrictions of the browser sandbox. If the browser or web page were
given access to the contents or filepaths of the client machine it
could used maliciously. You don't need to know the filepath to send the
file to the server - the browser will attach and send the file to the
form data.

regards,
-ad
Vibhu wrote:
Hello All,

I have a input box on the HTML page with the type set to file. What I
want is that when the value changes in the file textbox, it should give
me the full file path. I have even tried passing the value to a hidden
control but all it does is passes only the File Name and not the file
path.

How do I go about it. I tried checking GMAIL service (Compose Mail) but
all I could get is that they are passing the window and the file object
to a function, the code of which is not accessible.

Any help will be greatly valuable.

Regards,

Vibhu Bansal.
Jul 7 '06 #3
Hi Vibhu,

A submit action can have a target attribute. What you could do is create
a hidden IFRAME, make the FORM target the name of the IFRAME. When a
user clicks submit, the file will be uploaded outside the page the form
is on. Clear the form and the user can uload another one.

So:

<form id="uploadForm" ... other tags...>
<input type="file" name="upload">
<input type="button" value="Attach" onclick="upload()">
</form>

... javascript:

var frameIndex = 0;

function upload() {
myFrame = document.createElementId("IFRAME");
myFrame.name = 'frame' + frameIndex;
// ... make IFRAME hidden
document.body.appendChild(myFrame);
form = document.getElementById("uploadForm");
form.target = 'frame' + frameIndex;
form.submit();
frameIndex++;
}

Something like that. I have never done it, but it should work in theory.
Also note that if you exit the window all uploads that are busy are
cancelled, so you should wait for the myFrame.contentWindow.onload to be
triggered before you can leave the page.
Good luck,
Vincent
Vibhu wrote:
Hi,

The reason why I want the full path of the file is that I want the file
to be uploaded in the background while the user is still on the
webpage; just the way GMAIL is attching files. I am sure using AJAX
this can be achieved.

So what I want is that the GET method of the .html page is invoked in
the background that will upload the file from the client to the server.

Hope this helps.

Regards,

Vibhu Bansal.
admataz wrote:
>Hi Vibhu

what you're trying to do probably not allowed because of security
restrictions of the browser sandbox. If the browser or web page were
given access to the contents or filepaths of the client machine it
could used maliciously. You don't need to know the filepath to send the
file to the server - the browser will attach and send the file to the
form data.

regards,
-ad
Vibhu wrote:
>>Hello All,

I have a input box on the HTML page with the type set to file. What I
want is that when the value changes in the file textbox, it should give
me the full file path. I have even tried passing the value to a hidden
control but all it does is passes only the File Name and not the file
path.

How do I go about it. I tried checking GMAIL service (Compose Mail) but
all I could get is that they are passing the window and the file object
to a function, the code of which is not accessible.

Any help will be greatly valuable.

Regards,

Vibhu Bansal.
Jul 7 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Ben | last post: by
1 post views Thread by Monte Chan | last post: by
4 posts views Thread by rn5a | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.