上传文件的服务器路径。 [英] server path to upload the file.

查看:83
本文介绍了上传文件的服务器路径。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

,因为我和你多次讨论过。今天我遇到一些异常问题,当我试图将文件插入数据库(pdf文件)时。在本地机器上,它进展顺利。但是当我试图在服务器上运行这个应用程序时,它会显示一些异常,这是我的代码在本地机器上运行良好: -





hi everyone,
as i have discussed with you many times. today i am having problem with some exception that comes when i am trying to insert the file into database(pdf file). in local machine it''s going well. but when i am trying to run this application on server then it''s show some exception ,here is code of mine which i s running well in local machine :-


protected void btnsave_Click(object sender, EventArgs e)
    {
        if (flUpld.HasFile == false)
        {
            lblerror.Text = "select a file to upload";
        }
        else
        {
            try
            {
                string filename = flUpld.FileName;
                find =Request.ApplicationPath;
                flUpld.PostedFile.SaveAs(Server.MapPath(find+"//result//" + filename.Trim()));
                string path = find+"//result//" + filename.Trim();

                if (ChangeData.InsertResult(ddlcategory.SelectedValue.ToString(), ddlsubcategory.SelectedValue.ToString(),
                txttitle.Text, path))
                {
                    txttitle.Text = "";
                    lblerror.Text = "sucessfully submitted";
                }
                else
                {
                    lblerror.Text = "try again later ";
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
    }







当我是试图在服务器上上传这个网站然后尝试插入然后显示错误

例外: -







System.UnauthorizedAccessException:拒绝访问路径''D:\INETPUB \VHOSTS\sarkarirozgar.com \httpdocs\result\Andersens_Fairy_Tales_NT.pdf''。在System.IO .__ Error.WinIOError(Int32 errorCode,String maybeFullPath)at System.IO.FileStream.Init(String path,FileMode mode,FileAccess access,Int32 rights,Boolean useRights,FileShare share,Int32 bufferSize,FileOptions options,SECURITY_ATTRIBUTES secAttrs) ,System msgPath,Boolean bFromProxy,Boolean useLongPath,Boolean checkHost)在System.IO.FileStream..ctor(String path,FileMode mode,FileAccess access,FileShare share,Int32 bufferSize,FileOptions options,String msgPath,Boolean bFromProxy)。 System.Web.HttpPostedFile.SaveAs(String filename)中的IO.FileStream..ctor(字符串路径,FileMode模式)位于ADMIN:Manage_Manage_Results.btnsave_Click(Object sender,EventArgs e)中的d:\inetpub \vhosts\sarkarirozgar.com \\\_ttpdocs \ ADMIN \Manage_Results.aspx.cs:第70行





帮我解释为什么会这样,因为我已经提供了该文件夹的所有权限..帮帮我。



我的文件夹结构。



管理面板

-manageresult.aspx

-manageresult.aspx.cs



结果

userpanel



这样的意思是我试图保存pdf文件的文件夹是root。页面在admin文件夹下。




and when i am trying to upload this site on server and trying to insert then it show the error
exception :-



System.UnauthorizedAccessException: Access to the path ''D:\INETPUB\VHOSTS\sarkarirozgar.com\httpdocs\result\Andersens_Fairy_Tales_NT.pdf'' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at ADMIN_Manage_Results.btnsave_Click(Object sender, EventArgs e) in d:\inetpub\vhosts\sarkarirozgar.com\httpdocs\ADMIN\Manage_Results.aspx.cs:line 70


help me out why it is going on because i have provided all the permission to the folder.. help me out.

my structure of the folder.

ADMIN PANEL
-manageresult.aspx
-manageresult.aspx.cs

result
userpanel

like this means the folder where i m trying to save the pdf file is in root. and the pages are under the admin folder .

推荐答案

1)右键单击所需的文件夹

2)选择属性

3)选择选项卡安全

4)单击添加按钮

5)在输入要选择的对象名称(示例):下键入 ASPNET 。单击检查名称按钮。然后单击确定。

6)在组或用户名:下选择 ASPNET ,提供读取和执行,读取和写入权限。单击确定

7)然后再次单击添加按钮

8)在输入要选择的对象名称(示例):下键入网络服务 。单击检查名称按钮。然后单击确定。

9)在组或用户名:下选择网络服务。提供阅读&执行,读取和写入权限。单击确定
1) Right click the required folder
2) Select Properties
3) Select tab Security
4) Click Add button
5) Under "Enter the object names to select(examples):" type ASPNET. Click "Check Names" button". Then Click OK.
6) Select ASPNET under "Group or user names:" Provide Read & Execute, Read and Write permissions. Click OK
7) Then again click Add button
8) Under "Enter the object names to select(examples):" type NETWORK SERVICE. Click "Check Names" button". Then Click OK.
9) Select NETWORK SERVICE under "Group or user names:" Provide Read & Execute, Read and Write permissions. Click OK


这篇关于上传文件的服务器路径。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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