fileupload上传图片,本地测试没有问题,但是传到服务器后,上传图片老提示出错,服务器目录有777权限。
会是什么原因?
会是什么原因?
解决方案 »
- gridview导出到excel时第一行出现乱码(非列名)
- word转换html
- ◆求助高手:sys.application 为空或不是对象◆
- 通过鼠标移过控制div显示
- 读二进制文件的问题
- ASP.NET中DATASET数据导航问题
- 看了MSPetShop后的一些困惑
- 框架页中.页面相互刷新问题
- 关于网站会员密码的加密问题,请教设计过的同仁
- 怎么养把原有的数据库文件导入SQL里去呀
- 只有在配置文件或 Page 指令中将 enableSessionState 设置为 true 时,才能使用会话状态。还请确保在应用程序配置的 <configuration>\<system.web>\<httpModules> 节中包括 System.We
- PCM数据如何保存成wav格式
Try
If FileUpload1.PostedFile.FileName = "" Then
Label1.Text = "请选择文件!"
Else
Dim FilePath As String = FileUpload1.PostedFile.FileName
If IsAllowedExtension(FileUpload1) = True Then
Dim filename As String = FilePath.Substring(FilePath.LastIndexOf("\") + 1)
Dim serverpath1 As String = Server.MapPath("../uploads/") + Session.SessionID + filename
Dim serverpath2 As String = Server.MapPath("../uploads/") + System.DateTime.Now.ToString("yyy-MM-dd-hh-mm-ss") + filename
FileUpload1.PostedFile.SaveAs(serverpath1)
hiddenlabel1.Text = "uploads/" + Session.SessionID + filename
hiddenlabel2.Text = "uploads/" + System.DateTime.Now.ToString("yyy-MM-dd-hh-mm-ss") + filename
Dim img As New ClassLibrary.ImageThumbnail
img.Imagethumbnail(FilePath)
img.ReducedImage(0.2, serverpath2) '缩略图缩小的比列
Label1.Text = "上传成功!"
FileUpload1.Visible = False
bt_upload.Visible = False
Else
Label1.Text = "只能上传.jpg|.gif|.bmp的文件!"
End If
End If
Catch ex As Exception
Label1.Text = "上传图片发生错误!"
End Try End Sub好奇怪啊,本地测试没问题啊。服务器权限也没问题啊。请问路径这样是不是正确啊?
第二步,设置服务器上用来保存上传的图片的目录的权限.方法:选中文件夹,右键->属性->安全->添加, 输入everyone, 然后把该用户除了完全控制以外的权限全部打上勾这样做之后应该就没问题了
上传到的图片目录是: 我的域名/uploads服务器权限已经给了啊。还是不行啊。
但是一用域名访问操作的话,上传图片老是提示出错,点击上传的时候ie有个js提示错误:webformpostbackoption未定义。本地测试没有这个错误。
但是一用域名访问操作的话,上传图片老是提示出错,点击上传的时候ie有个js提示错误:webformpostbackoption未定义。本地测试没有这个错误。这样是不是还是权限的问题啊?
c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll
并限制为GET,HEAD,POST,DEBUG,并且不要将“确认文件是否存在”打勾。
--------------------------------------------------------------------------------未能找到路径“E:\鞋板\A-嘉成\A1703-5.JPG”的一部分。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.IO.DirectoryNotFoundException: 未能找到路径“E:\鞋板\A-嘉成\A1703-5.JPG”的一部分。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 堆栈跟踪:
[DirectoryNotFoundException: 未能找到路径“E:\鞋板\A-嘉成\A1703-5.JPG”的一部分。]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +1971376
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) +998
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access) +57
admin_add.IsAllowedExtension(FileUpload hifile) +57
admin_add.bt_upload_Click(Object sender, EventArgs e) +135
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.832; ASP.NET 版本:2.0.50727.832 看来是我的程序出错? 请高手帮我看看。
--------------------------------------------------------------------------------未能找到路径“E:\A228-33.JPG”的一部分。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.IO.DirectoryNotFoundException: 未能找到路径“E:\A228-33.JPG”的一部分。源错误: 执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 堆栈跟踪:
[DirectoryNotFoundException: 未能找到路径“E:\A228-33.JPG”的一部分。]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +1971376
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) +998
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access) +57
admin_add.IsAllowedExtension(FileUpload hifile) +57
admin_add.bt_upload_Click(Object sender, EventArgs e) +135
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.832; ASP.NET 版本:2.0.50727.832
看来是我的程序问题??麻烦高手帮我看看。
这个函数里的
System.IO.FileStream fs = new System.IO.FileStream(FileUpload1.PostedFile.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
有问题