MondeoST24
Member
- Joined
- Mar 9, 2006
- Messages
- 16
- Programming Experience
- Beginner
Hi,
I've got this code working to ftp an image
The problem is that when the image ends up on the ftp server its corrupted, it cant be opened as a jpeg?
Could this be something to do with the encoding?
Thanks
I've got this code working to ftp an image
VB.NET:
Dim request As FtpWebRequest = DirectCast(WebRequest.Create("server/" + txtRef.Text + ".jpg"), FtpWebRequest)
request.Method = WebRequestMethods.Ftp.UploadFile
request.Credentials = New NetworkCredential("leasing", "pass")
Dim sourceStream As New IO.StreamReader(Server.MapPath(".") + "\" + txtRef.Text + ".jpg")
Dim fileContents As Byte() = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd())
sourceStream.Close()
request.ContentLength = fileContents.Length
Dim requestStream As IO.Stream = request.GetRequestStream
requestStream.Write(fileContents, 0, fileContents.Length)
requestStream.Close()
Dim response As FtpWebResponse = DirectCast(request.GetResponse(), FtpWebResponse)
response.Close()
The problem is that when the image ends up on the ftp server its corrupted, it cant be opened as a jpeg?
Could this be something to do with the encoding?
Thanks