简体   繁体   中英

upload and download files ASP.NET C# IIS7

My requirement is, User uploads an excel file, i need to process that excel and store required info in DB and create new excel with required data for user on his computer.

I used fileupload control. I have created a folder in my application to store uploaded files. Once the user uploaded a file, i am taking that file and storing it in my application folder. Then I am processing it.

Now my user needs to save new excel file on his computer. For this, i provided a textbox for user to enter path where to store the new file.

everything is fine while running in VWD. But when i am running website using IIS7, i got few probs.

1) fileupload error: User has no access to create a file in my application folders.

2) IIS says destination directory does not exist. Because IIS cannot read the directory path on client computer.

I think both are some authentication issues.

Please guide me on this. If you have the other way in doing this please suggest

Thanks

For the upload of the file you just have to give your application's identity permission to modify the contents of your upload folder. You can do this either using the identity impersonate tag in your web.config and putting a user that has rights to modify or by giving the user of your application pool rights to modify your application's folder.

As for the download, you cannot create folders in an arbitrary directory on the user's computer across the internet. You can only access things inside the sandbox of the user's computer. If you were able to modify anything on the user's computer think of the security whole you would have created. What I would do is create the excel file and then stream it down to the user and then when the dialog pops up they can choose where to save the file to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM