By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,414 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,414 IT Pros & Developers. It's quick & easy.

get the full file path of file input field

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.