文件上传在服务器上如何工作?
我有以下问题:我有一个客户要在线上传 Excel 文件。需要将此 Excel 文件导入到数据库表中,我可以使用 openrowset
命令来完成此操作。导入后,我可以使用 GridView 显示数据。
现在,我引用了http://www.codeproject.com/KB/books/ASPNET20FileUpload。 aspx 和 http://msdn.microsoft.com/en-us/library/aa478971.aspx,但在这两个中,上传文件夹(目标)都是硬编码的。如何更改此设置以反映文件在服务器上的目的地?并且,完成此操作后,我如何使用 openrowset
提取 Excel 文件的内容?
此外,在部署之前如何在我的计算机上模拟整个过程?
I have the following problem: I have a client who will upload an Excel file online. This Excel file will need to be imported to a database table, which I can do using the openrowset
command. Once it has been imported, I can display the data using a GridView
.
Now, I have referred http://www.codeproject.com/KB/books/ASPNET20FileUpload.aspx and http://msdn.microsoft.com/en-us/library/aa478971.aspx, but in both of them, the upload folder (destination) is hardcoded. How can I change this to reflect the file's destination to be on the server? And, once this is done, how can I then use openrowset
to extract the contents of the Excel fie?
Additionally, how can I emulate the entire process on my machine before it is deployed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将文件存储在服务器上,例如..
,然后将其设置在连接字符串中,例如..
connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("~/temp/ xyz.xlsx");扩展属性=Excel 12.0;";
You can store your file on server like..
and then set that in connection string like..
connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath("~/temp/xyz.xlsx"); Extended Properties=Excel 12.0;";