如何从在ASP.net客户端使用一个文件? [英] How to use a file from a client in ASP.net?

查看:125
本文介绍了如何从在ASP.net客户端使用一个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道服务器不能访问客户端的硬盘或目录,但为什么当我硬$ C $目录c到我的应用程序可以访问我该文件并将其上传到一个SQL数据库?

I know the server cant access the hard drive or directories of a client, but why when I Hardcode the directory into my application can I access the file and upload it to a SQL database?

只是一个普通的按钮

 <asp:LinkButton ID="btnImportData" runat="server" OnClick="btnImportData_Click">Import Spreadsheet</asp:LinkButton>

然后$ C $后面

then the Code behind

  protected void btnImportData_Click(object sender, EventArgs e)
        {
            dbConn.uploadToExcel(@"C:\Users\spadmin\Desktop\ABI Employee List.xlsx");
        }

然后我可以使用该文件来更新我的数据库和它的作品。

Then I can use that file to update my database and it works.

他们为什么要那么说我不能使用目录从客户端?

Why do they then say I cant use directories from the client?

更新

<一个href=\"http://www.$c$cguru.com/csharp/.net/net_asp/controls/article.php/c19629/File-Uploading-in-ASPNET-20.htm\"相对=nofollow>如何上传使用服务器链接使用Server.Mappath

Link on how to upload to server using Server.Mappath

推荐答案

在code访问服务器上的文件。无论哪个PC的用于访问的网络服务器,它总是在寻找服务器的C盘上。

The code accesses the file on the server. Regardless of which PC you use to access the web server it is always looking on the server's C drive.

这篇关于如何从在ASP.net客户端使用一个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆