在asp.net中上传文件 [英] File uploading in asp.net

查看:73
本文介绍了在asp.net中上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

专家,

我正在使用asp.net FileUpload控件上传图像文件.

我正在使用以下代码.

Hi Expert,

I am uploading image file using asp.net FileUpload control.

I am using following code.

try
        {
            string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
            string fileExtension = Path.GetExtension(FileUpload1.PostedFile.FileName);
            string fileLocation = Server.MapPath("~/images/"  + fileName);


                FileUpload1.SaveAs(fileLocation);

        }
        catch(Exception ex)
        {
            Response.Write(ex.StackTrace.ToString());
        }</pre>



在本地对我来说很好.
但在服务器上,它



Locally it working fine for me.
but on server it

FileUpload1.SaveAs(fileLocation);

引发以下异常

throws following exception

at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in :0 at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize) [0x00000] in :0 at (wrapper remoting-invoke-with-check) System.IO.FileStream:.ctor (string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,int) at System.IO.File.Create (System.String path, Int32 bufferSize) [0x00000] in :0 at System.IO.File.Create (System.String path) [0x00000] in :0 at System.Web.HttpPostedFile.SaveAs (System.String filename) [0x00000] in :0 at nridubai_admin_tstFileUpload.Button5_Click (System.Object sender, System.EventArgs e) [0x00000] in :0



请注意,我正在服务器上使用Mono平台.

请帮帮我.

在此先感谢



Please note that i am using mono platform on server.

Please help me.

Thanks in advance

推荐答案

尝试为aspnet accout设置必要的权限

问候
塞巴斯蒂安
try to set necessary permissions for aspnet accout

Regards
Sebastian


这篇关于在asp.net中上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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