在ASP.NET VB中上传图片 [英] image upload in asp.net vb

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

问题描述

我正在做一个项目,其中有一个图像上传过程,
我使用以下代码
================================================== ======================

 公共 功能 UploadThisFile( ByVal 上传 As  FileUpload)

             Dim  theFilename  As   String 
             Dim  str_Custfilename  As  字符串
            如果上传.HasFile然后
                str_Custfilename = upload.FileName
                theFilename = Path.Combine(HttpContext.Current.Server.MapPath(" ), str_Custfilename)
                upload.SaveAs(theFilename)
                ' 文件名是FileName,需要存储在数据库中.
                System.Threading.Thread.Sleep( 8000 )
            其他
                str_Custfilename = " 
            结束 如果

            返回 "  + str_Custfilename

        结束 功能 


================================================== ==========================

但服务器端出现错误

错误消息是

Access to the path ''D:\CustomerData\webspaces\webspace_00110365\wwwroot\uploadedimages\blackflag.jpg'' is denied.

Line 105:                str_Custfilename = upload.FileName
Line 106:                theFilename = Path.Combine(HttpContext.Current.Server.MapPath("~/uploadedimages/"), str_Custfilename)
Line 107:                upload.SaveAs(theFilename)
Line 108:                '' the file name is theFileName needs to be stored in the database.
Line 109:                System.Threading.Thread.Sleep(8000)


请帮我吗?

解决方案


请仔细阅读以下内容-

.NET图片上传 [ fileupload-control-save-images-database.html [ ^ ]

您需要检查三件事:
1)该文件是否存在,并因此而抱怨.
2)文件夹"uploadedimages"是否存在,名称是否正确(包括大小写)? (取决于您的主机,文件夹名称可能区分大小写)
3)该文件夹是否对所有人都具有写权限,或者至少对应用程序要在其下运行的帐户具有写权限?


i am doing a project, there is an image upload process in it,
i use the following code
=========================================================================

Public Function UploadThisFile(ByVal upload As FileUpload)

            Dim theFilename As String
            Dim str_Custfilename As String
            If upload.HasFile Then
                str_Custfilename = upload.FileName
                theFilename = Path.Combine(HttpContext.Current.Server.MapPath("~/uploadedimages/"), str_Custfilename)
                upload.SaveAs(theFilename)
                ' the file name is theFileName needs to be stored in the database.
                System.Threading.Thread.Sleep(8000)
            Else
                str_Custfilename = "default_news.jpg"
            End If

            Return "/uploadedimages/" + str_Custfilename

        End Function


==============================================================================

but i have an error in server side

the error message is

Access to the path ''D:\CustomerData\webspaces\webspace_00110365\wwwroot\uploadedimages\blackflag.jpg'' is denied.

Line 105:                str_Custfilename = upload.FileName
Line 106:                theFilename = Path.Combine(HttpContext.Current.Server.MapPath("~/uploadedimages/"), str_Custfilename)
Line 107:                upload.SaveAs(theFilename)
Line 108:                '' the file name is theFileName needs to be stored in the database.
Line 109:                System.Threading.Thread.Sleep(8000)


pl''s help me ?

解决方案

Hi,
Go through the following-

.NET Image Uploading[^]

fileupload-control-save-images-database.html[^]


You need to check three things:
1) Does the file exist and it is complaining for that reason.
2) Does the folder "uploadedimages" exist and is the name absolutely correct, including case? (depending on your host, folder names can be case sensitive)
3) Does the folder have write permissions to everybody, or at least to the account the app is to run under?


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

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