访问不在服务器中的本地计算机中的文件 [英] access a file in a local machine not in a server

查看:78
本文介绍了访问不在服务器中的本地计算机中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我有一个位于服务器的网站,用户可以通过本地机器访问网站。

网站让用户上传Excel工作表,然后在gridview中显示数据。但是,当用户上传excel表时,网站从服务器搜索文件而不是本地机器,当然也找不到该文件。



我的问题:如何让网站从本地机器搜索文件而不是服务器?



谢谢

hello

I have a website located in a server and the user can access the website from his local machine.
The website let the user to upload an excel sheet and then display the data in a gridview. But, when the user upload the excel sheet, the website search about the file from the server not from the local machine and it of course does not find the file.

my Question: How I can let the website search about the file from local machine not from the server?

thank you

推荐答案

根据定义,要允许访问某台计算机上的任何文件,您需要使该计算机充当服务器。它几乎可以是任何类型的服务器:Windows,FTP,HTTP或自定义服务上始终可用的共享文件服务。



但是,它与ASP.NET无关,除非您想在某些本地计算机上的某些HTTP服务器上启用ASP.NET,但我认为这违反了您的请求的要求。出于重要的安全原因,任何Web应用程序都无法访问客户端计算机上的任何内容,甚至对运行HTTP服务器的主机上的文件系统对象的访问也受到严格限制,至少对于所有非无意义的服务器而言。自己想一想:如果允许Web应用程序访问客户端计算机,谁会想要使用Web?



-SA
By definition, to allow access to any file on some machine, you need to make this machine acting as a server. It could be almost any kind of server: shared file service always available on Windows, FTP, HTTP, or custom service.

However, it is unrelated to ASP.NET, unless you want to enable ASP.NET on some HTTP server on some local machine, but I think this is against the requirements of your request. For important security reasons, no Web application can access anything on client computer, and even the access to the file system objects on the host running the HTTP server is strictly limited, at least for all non-nonsense servers. Think by yourself: who would want to use the Web if it would allow the Web application to access client computers?

—SA


如果您创建一个名为upload的文件夹,并且在此文件夹中创建一个包含服务器用户名的文件夹,并将用户上传的文件放入该文件夹,则可以实现此目的。现在,您可以从服务器上的本地驱动器读取文件,然后在gridview中显示数据。
This can be achieved if you create a folder with the name "upload" and inside this folder create a folder with the username in the server and place the files uploaded by the user to that folder. Now you can read the file from the local drive on the server and then display the data in the gridview.


这篇关于访问不在服务器中的本地计算机中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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