1

As we all know that we can not get the full path of the file using File Upload control, we will follow the process for saving the file in to our application by creating a folder and by getting that folder path as follows

Server.MapPath

But i am having a scenario to select 1200 excel files, not at a time. I will select each and every excel file and read the requied content from that excel and saving the information to Database. While doing this i am saving the files to the Application Folder by creating a folder Excel. As i am having 1200 files all these files will be saved in to this folder after each and every run.

Is it the correct method to follow or not I don't know

I am looking for an alternative solution rather than saving the file to folder. I would like to save the full path of file temporarily until the process was executed.

So can any tell me the best way as per my requirement.

Developer
  • 8,390
  • 41
  • 129
  • 238
  • 1
    I don't see a problem with your current approach. – Zaldy Baguinon Dec 02 '11 at 05:18
  • I didn't say i am having trouble, i am looking for an alternative solution if any.. – Developer Dec 02 '11 at 05:25
  • 1
    Do you mean that you currently copy the files into your application/Excel folder? You dont need to – Grrbrr404 Dec 02 '11 at 05:47
  • I don't want to save the file to database.. `Grrbrr404` yeah currently saving the files to `application folder` and i don't want that – Developer Dec 02 '11 at 06:04
  • I was saying I don't see any problem if you are going to implement what you had in mind. It means that you can do it while you can and then optimize later. In my opinion, it is good to have a copy of the uploaded file to the server (as a proof that the server did not make booboo upon accepting the file upload) then process it later. If it is user uploaded, it will also help to troubleshoot if your **processing** code has a bug or it is the file upload part. It will also serve as your proof that the user had uploaded an invalid excel file which takes out the blame from you. – Zaldy Baguinon Dec 02 '11 at 07:50

1 Answers1

4

Grrbrr404 is correct. You can perfectly take the byte [] from the FileUpload.PostedFile and save it to the database directly without using the intermediate folder. You could store the file name with extension on a separate column so you know how to stream it later, in case you need to.

The debate of whether it's good or bad to store these things on the database itself or on the filesystem is very heated. I don't think either approach is best over the other; you'll have to look at your resources and your particular situation and make the appropriate decision. Search for "Store images on database or filesystem" in here or Google and you'll see what I mean.

See this one, for example.

Community
  • 1
  • 1
Icarus
  • 63,293
  • 14
  • 100
  • 115