我在服务器上发布项目后文件上传不起作用 [英] File upload not working after i have published my project on server

查看:177
本文介绍了我在服务器上发布项目后文件上传不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在服务器上发布了我的应用程序.所有学院都在在线使用它.该应用程序有一个名为admin的用户.管理员每天通过文件上传控件上传文件(.csv).上传后,文件中的数据显示在下面的网格视图中.该文件应存在于用户计算机上的c:驱动器中.但是错误显示路径无效.问题在于它采用了服务器路径.它正在搜索服务器C:驱动器上的文件.如何解决此问题.

I have published my application on my server. All faculties are using it on line. The application have one user called admin. Admin daily upload a file (.csv) through a file upload control. The data in the file is shown below in grid view after uploading. The file should be present on user computer in c: drive. But the error is showing invalid path. The problem is that it taking the servers path. It is searching the file on servers C: drive. How to overcome this problem.

推荐答案

您无法访问用户硬盘-他必须使用上载控件浏览到文件,然后按一个按钮-然后可以上传文件(但不能提供有关该文件来自何处的任何信息,安全性是不允许的).

另外,您可以编写软件,该软件可以在他的PC上作为服务运行并自动上传.

但是服务器无法伸出"用户PC并仅抓取文件.有很多专门用于防止这种情况的软件!
You can''t access the users HDD - he has to browse to the file with an upload control, and press a button - then the file (but not any information as to where it came from, security won''t allow that) can be uploaded.

Alternatively, you could write software which runs as a service on his PC and uploads it automatically.

But the server cannot "reach out" into the users PC and just grab the file. There is a lot of software out there specifically to prevent that!


首先,从csv文件获取数据的逻辑是错误的.
您无需使用用户计算机来读取该上传的csv文件.

您需要做的是

1)首先选择该csv文件并将其上传到您的服务器

2)从该上传文件中读取数据,并将其显示在网格中.
就像您将该文件上传到服务器上的temp目录一样
然后使用server.mappath("~temp/first.csv");可以正常工作..


从用户计算机读取文件是个坏主意.因为如果我是您的应用程序的用户,而我的PC中没有c:\ ,而我却没有 c:\,而我使用D:\来安装Windows,则您的系统无法在我的PC中工作.来自用户PC的文件数据是错误的主意.因此,请始终上传并保存该文件,并从服务器目录使用该文件.

并且如果由于安全原因不想将该文件存储在服务器上,则可以在从该文件读取数据之后使用system.io.file类删除该文件..

那是更好的方法.
First of all your logic for getting data from your csv file is wrong.
you need not use the user computer for reading that uploaded csv file.

what you need to do is,

1) first select and upload that csv file to your server

2) read the data from that uploaded file and display it to your grid.
like if you upload that file to your temp directory held on server
then use server.mappath("~temp/first.csv"); that working fine..


reading file from user computer is the bad idea. because if i am the user of your application and i have no c:\ in my PC instead c:\ i use D:\ for my windows to install, then your system not work in my PC.. that''s why reading file data from user PC is wrong idea. so always upload and save that file and use that file from server''s directory.

and if you don''t want to store that file on server because of security reasons then you can delete that file using system.io.file class after you read data from that file..

that''s the better way.


heloo ... Qureshali514


如果要将任何文件(例如csv或图像)上载到IIS服务器,则必须完全控制上载的文件夹...那么只有您才能从服务器访问该文件...

右键单击要在IIS中上传的文件夹,然后在属性">安全性为IIS用户提供完全权限"中,您便可以从客户端访问此文件....
heloo...Qureshali514


If you are uploading any Files like csv, or Images into IIS server You have to give full control for the uploaded folder... Then only you will be able to acces that file from the server...

right click the folder where you are uploading in IIS and In properties>Securities give full Permissions for IIS users then you will be able to access this file from clients....


这篇关于我在服务器上发布项目后文件上传不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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