如何上传到服务器端? [英] how to upload to the server side??!!

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

问题描述

我正在尝试将照片上传到我的网站文件夹"upload"

但是我不能写那个文件夹的路径?
怎么写那个浴????


''/''应用程序中的服务器错误.

SaveAs方法配置为需要root用户路径,而路径〜\ content \ news \ upload \ 55.jpg"不是root用户.

说明:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息.

异常详细信息:System.Web.HttpException:将SaveAs方法配置为需要root用户路径,而路径〜\ content \ news \ upload \ 55.jpg"却不是root用户.

源错误:


第14行:conn.Close()
第15行:
第16行:FileUpload1.SaveAs("\\ fs4-n01 \ stor3wc2dfw1 \ 509429 \ 509697 \ www.ittejahatcenter.com \ web \ content \ news \ upload \"& imgname&".jpg")
第17行:Else
第18行:MsgBox("no iamge")

I am trying to upload photo to my website folder "upload"

but i can''t write the path of that folder ???

how to write that bath ????


Server Error in ''/'' Application.

The SaveAs method is configured to require a rooted path, and the path ''~\content\news\upload\55.jpg'' is not rooted.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The SaveAs method is configured to require a rooted path, and the path ''~\content\news\upload\55.jpg'' is not rooted.

Source Error:


Line 14: conn.Close()
Line 15:
Line 16: FileUpload1.SaveAs("\\fs4-n01\stor3wc2dfw1\509429\509697\www.ittejahatcenter.com\web\content\news\upload\" & imgname & ".jpg")
Line 17: Else
Line 18: MsgBox("no iamge")

推荐答案

您确定该位置存在吗?
只需使用相对路径声明即可:
Are you sure that location exists?
Just use relavtive path declaration as:
string saveDir = @"\Upload\"+Server.HtmlEncode(FileUpload1.FileName);
FileUpload1.SaveAs(saveDir);



否则请尝试使用MapPath:



otherwise try to use MapPath:

FileUpload1.SaveAs(Server.MapPath("~/Upload/") & FileUpload1.FileName)



http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx [ ^ ]

祝你好运!



http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx[^]

Good luck!


非常感谢:thumbsup:
非常感谢:thumbsup:
非常感谢:thumbsup:
thank you so much:thumbsup:
thank you so much:thumbsup:
thank you so much:thumbsup:


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

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