Hi,
I am developing a vb.net application in which i uploading
some paramenters which is given below
"FirstName,MiddleName,LastName,MyImage".
Uploading is done successfully but image is not showing at webpage. It is uploading FirstName, MiddleName, LastName not Myimage.
My Code is below:
myUri = New Uri("https://www.mysite.com/apis/CreateMyContact.cfm")
data = data.Append("&FirstName=" & System.Web.HttpUtility.UrlEncode(Dharm))
data = data.Append("&MiddleName=" & System.Web.HttpUtility.UrlEncode(Chand))
data = data.Append("&LastName=" & System.Web.HttpUtility.UrlEncode(Dhingra))
data = data.Append("&NickName=" & System.Web.HttpUtility.UrlEncode(Dharmu))
Dim fs As System.IO.FileStream = Nothing
Dim imgByte() As Byte = Nothing
Try
fs = System.IO.File.Open(image_path, IO.FileMode.Open, FileAccess.Read)
ReDim imgByte(fs.Length)
fs.Read(imgByte, 0, fs.Length)
fs.Close()
fs.Dispose()
fs = Nothing
Catch ex As System.Exception
End Try
If Not IsNothing(imgByte) Then
data = data.Append("&PhotoBinary=" & System.Web.HttpUtility.UrlEncode(imgByte)) 'image_path)) '
End If
'Create a byte array of the data we want to send
Dim requestBytes As Byte() = System.Text.UTF8Encoding.UTF8.GetBytes(data.ToString())
Dim oWeb As New System.Net.WebClient()
oWeb.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
Try
Dim bytRetData As Byte() = oWeb.UploadData(myUri, "POST", requestBytes)
Catch ex As WebException
End Try
This code is working successfully but image is not uploading.
Please guide me if i did wrong something in code.
Regards
Dharmchand dhingra