Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3024
  • Last Modified:

ASP.NET file upload component in chrome

The file input type does not work in chrome and i think safari

when i try to upload a file only the filename AND NOT THE PATH is passed from the file upload component.

this is an issue because for the code to work it needs to know where the file is.

I am using the simplest method

        <asp:FileUpload ID="File1" runat="server" />

 string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
            string SaveLocation = Server.MapPath("") + "\\" + File1.PostedFile.FileName;
                Response.Write("The file has been uploaded." + fn);
            catch (Exception ex)
                Response.Write("Error: " + ex.Message);

which returns the actual filename and not the path

thanks in advance.
3 Solutions
Due to security reasons of client machine, we can't read file path from program.

Anyhow file upload control can save the file in server. No need to know the client machine file path from program. Refer below link for simple explanation of file upload.
That has nothing to do with the file upload component. It is a browser thing. Some browsers pass the complete file path, others don't. Building code that relies on the complete path of an uploaded file, is not going to work in all browsers.
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

myshipAuthor Commented:
here is my issue.. i need to be able to select files and then use ftp

i am not using the saveas method

so how can i do that?

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now