hello friends...

i have done it using FileUpload1.PostedFile.FileName ....
but the problem is everything is working fine in IE ....but not in mozilla...safari....

actually i want to get the full path of the selected file...not the file name only..........


thank you.....

Dani AI

Generated

Short answer: modern browsers do not expose a user’s full local path to a web page for privacy and security, so the behavior seen in Internet Explorer (where a full path sometimes appeared) is not reliable across Firefox, Chrome, Safari or current Edge. reported the symptom, and tried server-side approaches, and correctly found that plain JavaScript cannot force the browser to reveal the client filesystem path.

Why: revealing a full client path can leak usernames, mounted drives or network locations. Browsers therefore provide the filename and file metadata but not an absolute client path. This is by design and cannot be bypassed from ordinary web pages.

Practical alternatives and examples:

  • If the goal is to show the original filename or read file metadata, use the HTML5 File API to get file.name, file.size, file.type, etc.:
<input id="f" type="file" />
<script>
document.getElementById('f').addEventListener('change', e => {
  const file = e.target.files[0];
  if (file) {
    console.log('name:', file.name);
    console.log('size:', file.size);
  }
});
</script>
  • If the real need is to preserve a folder structure when multiple files are uploaded, some browsers support directory selection and provide a relative path for each file (nonstandard behavior available in certain engines). Example (browser support varies):
<input id="dir" type="file" webkitdirectory multiple />
<script>
for (const f of document.getElementById('dir').files) {
  console.log(f.webkitRelativePath || f.name);
}
</script>

Server-side guidance: never trust client-supplied values. Store uploads with server-generated names or sanitized filenames, validate types and sizes, and scan for malware. If an absolute client path is absolutely required inside a controlled intranet, the only practical (but risky and non-portable) options are a trusted native helper, an enterprise-only ActiveX/signed component, or a custom protocol handler—none are suitable for public web apps.

Summary: treat the lack of a client full-path as a browser security feature and change the upload workflow to rely on filenames, relative paths (where supported), or explicit user input rather than attempting to extract the full local path.

Recommended Answers

All 3 Replies

hi
by using filename you will get full like this

if (fileup1.HasFile)
        {
            Response.Write(fileup1.PostedFile.FileName);
        }

that wont work in mozilla .....i even trid with javascript but no use. :(

fileUpload1.SaveAs(Server.MapPath(“~/uploads/”) + System.IO.Path.GetFilename(fileUpload1.FileName));

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.