0

I am uploading image to the server in an asp.net page.Here is the code..

Code:

protected void Button2_Click1(object sender, EventArgs e)
        {

           //resimyolu = "~/r/" + FileUpload1.FileName;
           FileUpload1.SaveAs(Server.MapPath("~/r/a.png"));
           FileUpload1.SaveAs("d:/upresim/a.png");
           Image1.ImageUrl = "~/r/a.png";

        }

the 'r' folder is the image folder in my project.when I add a picture to the 'r' folder at runtime,it works succesfully on local IIS ,but when I publish my project and host it on a server(remote server) the web page is opening in the browser ,but when I click button2 to add client image(which client user selected from his computer) to the project an error appears like below..

Runtime Error 
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
4

2 回答 2

0

问题是这条线。

FileUpload1.SaveAs("d:/upresim/a.png");

将其更改为将有所帮助。

FileUpload1.SaveAs("d:\\upresim\\a.png");

如果您的代码,请避免使用此类硬编码路径。更换机器时会遇到问题。Server.MapPath总是更好的方法。如果您不想保存在 Web 目录中,则应始终从配置中获取基本路径。

于 2013-03-21T11:14:35.740 回答
0

按照错误消息中的建议,禁用 web.config 上的自定义错误以查看问题所在。

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>
于 2013-03-21T10:56:05.443 回答