Error msg: Failed to map the path '/' in file upload
-
Hi guys i installed my vs2005 in c drive and i have my project in d drive in that project i am doing fileupload concept i given server mappath to save file: fileupload1.PostedFile.SaveAs(Server.MapPath("\") & "OnLineResumes\" & filename) now my quest is the uploaded file will go and store in c drive or d drive inside the project..., Means, in which drive it will consider as server mappath? And see this is my code and its not at all storing the upload file in any of the drive... I am getting error message as Failed to map the path '/' See this is my code in button click event: Dim sqlquery As String = "-" Dim docid As Integer sqlquery = "select isnull(max(ResumeId),1000)+1 from tblonlineresume" sqlcmd = New SqlCommand(sqlquery, sqlconn) sqlcmd.Connection.Open() If sqlcmd.ExecuteScalar() > 0 Then docid = sqlcmd.ExecuteScalar End If sqlcmd.Connection.Close() sqlcmd.Dispose() Dim filename As String = docid & System.IO.Path.GetFileName(fileupload1.PostedFile.FileName) strdate = txtdob.Text If Mid(strdate, 2, 1) = "/" Then strdate = "0" & strdate If Mid(strdate, 5, 1) = "/" Then strdate = Left(strdate, 3) & "0" & Mid(strdate, 4, 6) txtdob.Text = Mid(strdate, 4, 3) & Mid(strdate, 1, 2) & Mid(strdate, 6, 5) Try sqlcmd = New SqlCommand("submitOnlineResume'" & ddlJob.SelectedValue & "','" & txtName.Text & _ "',' " & txtemail.Text & "','" & txtQualify.Text & "','" & ddlYpass.SelectedValue & "','" & _ Mid(txtdob.Text, 4, 3) & Mid(txtdob.Text, 1, 3) & Mid(txtdob.Text, 7, 4) & "','" & _ ddlfarea.SelectedValue & "','" & ddlAspec.SelectedValue & "','" & txtsset.Text & _ "','" & filename & "'", sqlconn) sqlcmd.Connection.Open() sqlcmd.ExecuteScalar() fileupload1.PostedFile.SaveAs(Server.MapPath("\") & "OnLineResumes\" & filename) lblMessage.Text = "The file has been uploaded." sqlcmd.Connection.Close() sqlcmd.Dispose() Catch ex As Exception lblMessage.Text = ex.Message Finally End Try sqlcmd.Connection.Close() sqlcmd.Dispose()
Thanks & Rega
-
Hi guys i installed my vs2005 in c drive and i have my project in d drive in that project i am doing fileupload concept i given server mappath to save file: fileupload1.PostedFile.SaveAs(Server.MapPath("\") & "OnLineResumes\" & filename) now my quest is the uploaded file will go and store in c drive or d drive inside the project..., Means, in which drive it will consider as server mappath? And see this is my code and its not at all storing the upload file in any of the drive... I am getting error message as Failed to map the path '/' See this is my code in button click event: Dim sqlquery As String = "-" Dim docid As Integer sqlquery = "select isnull(max(ResumeId),1000)+1 from tblonlineresume" sqlcmd = New SqlCommand(sqlquery, sqlconn) sqlcmd.Connection.Open() If sqlcmd.ExecuteScalar() > 0 Then docid = sqlcmd.ExecuteScalar End If sqlcmd.Connection.Close() sqlcmd.Dispose() Dim filename As String = docid & System.IO.Path.GetFileName(fileupload1.PostedFile.FileName) strdate = txtdob.Text If Mid(strdate, 2, 1) = "/" Then strdate = "0" & strdate If Mid(strdate, 5, 1) = "/" Then strdate = Left(strdate, 3) & "0" & Mid(strdate, 4, 6) txtdob.Text = Mid(strdate, 4, 3) & Mid(strdate, 1, 2) & Mid(strdate, 6, 5) Try sqlcmd = New SqlCommand("submitOnlineResume'" & ddlJob.SelectedValue & "','" & txtName.Text & _ "',' " & txtemail.Text & "','" & txtQualify.Text & "','" & ddlYpass.SelectedValue & "','" & _ Mid(txtdob.Text, 4, 3) & Mid(txtdob.Text, 1, 3) & Mid(txtdob.Text, 7, 4) & "','" & _ ddlfarea.SelectedValue & "','" & ddlAspec.SelectedValue & "','" & txtsset.Text & _ "','" & filename & "'", sqlconn) sqlcmd.Connection.Open() sqlcmd.ExecuteScalar() fileupload1.PostedFile.SaveAs(Server.MapPath("\") & "OnLineResumes\" & filename) lblMessage.Text = "The file has been uploaded." sqlcmd.Connection.Close() sqlcmd.Dispose() Catch ex As Exception lblMessage.Text = ex.Message Finally End Try sqlcmd.Connection.Close() sqlcmd.Dispose()
Thanks & Rega
-
Hi, Test this code: fileupload1.PostedFile.SaveAs(Server.MapPath("~\") & "OnLineResumes\" & filename)
Hey man its great, So we have to mention ~ symbol, Ok but one of my senior did with out that symbol, but code is same what i have mention before, So how he can get it?, whats wrong in my code?
Thanks & Regards, NeW OnE, please don't forget to vote on the post