大家好,我被困在我的代码中。 i我试图使用visual studio 2010在我的asp网页上上传图片。 只是尝试我使用此代码
Hi everyone i am stuck in my code. i am trying to upload a image on my asp web page using visual studio 2010. for just try i used this code
protected void Button1_Click(object sender, EventArgs e) { FileUpload1.SaveAs(Server.MapPath("~/image/"")); }i在我的项目中有像webapplication的图像文件夹 - image 。 但是当我每次尝试运行代码都会出现同样的错误时,找不到路径的一部分。
i have image folder on my project like webapplication - image. but when i try to run the code everytime it gives the same error, could not found the part of path.
FileUpload1.SaveAs(Server.MapPath("~/")); FileUpload1.SaveAs(Server.MapPath("~"));i尝试了所有这些,因为我通过互联网检查发现这些不同的方式,但没有人为我工作。我检查文件夹图像也有写入权限。 所以请任何人给我解决方案。 提前感谢。
i tried all these because i found by checking on internet these different ways, but no one work for me. i check the folder image has a write permission too. so please can anyone give me solution. thanks in advance.
推荐答案如果您的网络表单和图像文件夹在同一目录中,请尝试以下代码 If you have your web form and image folder in same directory then try following code protected void Button1_Click(object sender, EventArgs e) { FileUpload1.SaveAs(Server.MapPath("image/"+FileUpload1.FileName)); }
您在上传图片时缺少文件名,所以我添加了 FileUpload1.FileName
If fu_data.HasFile Then Dim extension As String = Path.GetExtension(fu_data.PostedFile.FileName) Dim filepath As String = "DLR_Data/" & id & extension fu_data.SaveAs(Server.MapPath(filepath)) btn_save.Enabled = False lbl_msg.Text = "Data Inserted Successfully" End If
嗨sandeep, 谢谢。 i尝试了这个,但它不起作用。我不知道我做错了什么。 Hi sandeep, thank you. i tried this but it dose`t work. i don`t know whats wrong i did.
更多推荐
在asp.net页面中使用fileupload控件上传图片
发布评论