0

I am using a FileUpload to get a file from a user with ASP.NET. The code that I am using is:

string strConn = "Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=" + FileUpload1.PostedFile.FileName;

So my question is this: is the file upload temporary storing the file somewhere and then the code can grab it, or is the file upload just a string path to where my file is? If latter then If I have this page live, and a user from a client side selects a path, will this code look for the file on server's computer or the user's computer?

Thanks for answering.

4
  • 1
    Look at the above msdn.microsoft.com/en-us/library/…
    – kostas ch.
    Commented Jun 14, 2013 at 14:30
  • so based on what I read it means that it grabs the file from client side and saves it on the server side, but I have to tell it to save the file. So If I don't tell it to save the file, can I just read it, put it in a data set and do nothing with it as in not save it, discard it? Since I will not need it once I have the contents inside a data set. Also if you answer my question, please answer it with an answer so I can mark it correct. Thanks
    – Bagzli
    Commented Jun 14, 2013 at 14:39
  • 1
    If you don't want to save the file on the server. You could always save the posted file in memory (a Dataset) and then add the file into Session state. The issue is, you would have to use a third party API to manipulate the file when retrieving from memory. See stackoverflow.com/questions/262341/…
    – JAKEtheJAB
    Commented Jun 14, 2013 at 16:16
  • It's ok for the point. I am happy my comment helped you. :)
    – kostas ch.
    Commented Jun 14, 2013 at 16:47

1 Answer 1

0

If the file is never "uploaded" to a server or a database, where your asp.net application is running, then your application cannot serve the file. The file won't magically appear of the client's machine if there is no way for the client to download the file from your server or database.

The FileUpload control in ASP.NET just posts the file via HTTP to your web application. You can grab the bytes from the posted file and save it somewhere in your server's file system or database.

Here are some simple examples of how to save a posted file from an asp.net FileUpload control: http://aspdotnet-viz007.blogspot.com/2013/02/file-upload-control-in-aspnet-and.html

1
  • I am not trying to make the file appear on the client's side, you misread the question.
    – Bagzli
    Commented Jun 14, 2013 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.