Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


ASP.NET file upload component in chrome

Posted on 2010-10-11
Medium Priority
Last Modified: 2012-06-27
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.
Question by:myship
LVL 12

Assisted Solution

rajapandian_81 earned 664 total points
ID: 33882222
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.

LVL 28

Assisted Solution

sybe earned 1336 total points
ID: 33882484
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.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 28

Expert Comment

ID: 33882503

Author Comment

ID: 33901281
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?

LVL 28

Accepted Solution

sybe earned 1336 total points
ID: 33901860

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question