X
XxLicherxX
Hello everyone,
I have created an application that generates some files. What I want
the application to do now is to automatically FTP these files to a
webserver. I have started implementing an FTP client into my code. I
can log into my FTP Server, PWD, CWD, etc just fine.
The problem starts when I try to upload a file. The part of the code
that is supposed to upload the file will run without any errors, but
when I login to my FTP site, the file I just tried to upload is not
there.
Below is the code snippet I am using (I found it online, and changed it
a tad bit) I think I understand most of it, but obviously not
everything, otherwise it would be working. Can someone tell me where I
am going wrong?
strTemp = responseData 'Response data is the result I get
after sending the
PASV command
'This looks like it somehow calculates the port that will be used for
transferring data. I have no idea how this formula works.
i = strTemp.LastIndexOf(",")
j = strTemp.LastIndexOf(")")
tPort = CInt(strTemp.Substring(i + 1, j - i - 1))
strTemp = strTemp.Substring(1, i - 1)
j = i
i = strTemp.LastIndexOf(",")
tPort = 256 * CInt(strTemp.Substring(i + 1, j - i - 2)) + tPort
'Client we will use for uploading the files to the webserver.
Dim uploadPort As New TcpClient(server, tPort)
Dim mDataStream As NetworkStream = uploadPort.GetStream()
MsgBox(tPort)
ReDim mBytes(FileLen("C:\test.xls"))
FileToUpload = File.OpenRead("C:\test.xls")
q = FileToUpload.Read(mBytes, 0, FileLen("C:\test.xls"))
'Trying to upload here, not sure what the 16384 refers to.
intTmp = 16384
Do While k < mBytes.Length
If mBytes.Length - k < 16384 Then
intTmp = mBytes.Length - k
End If
FileMemory.Write(mBytes, k, intTmp)
FileMemory.WriteTo(mDataStream)
k += intTmp
System.Console.Out.WriteLine(k)
Loop
mDataStream.Close()
uploadPort.Close()
Any help would be greatly appreciated.
I have created an application that generates some files. What I want
the application to do now is to automatically FTP these files to a
webserver. I have started implementing an FTP client into my code. I
can log into my FTP Server, PWD, CWD, etc just fine.
The problem starts when I try to upload a file. The part of the code
that is supposed to upload the file will run without any errors, but
when I login to my FTP site, the file I just tried to upload is not
there.
Below is the code snippet I am using (I found it online, and changed it
a tad bit) I think I understand most of it, but obviously not
everything, otherwise it would be working. Can someone tell me where I
am going wrong?
strTemp = responseData 'Response data is the result I get
after sending the
PASV command
'This looks like it somehow calculates the port that will be used for
transferring data. I have no idea how this formula works.
i = strTemp.LastIndexOf(",")
j = strTemp.LastIndexOf(")")
tPort = CInt(strTemp.Substring(i + 1, j - i - 1))
strTemp = strTemp.Substring(1, i - 1)
j = i
i = strTemp.LastIndexOf(",")
tPort = 256 * CInt(strTemp.Substring(i + 1, j - i - 2)) + tPort
'Client we will use for uploading the files to the webserver.
Dim uploadPort As New TcpClient(server, tPort)
Dim mDataStream As NetworkStream = uploadPort.GetStream()
MsgBox(tPort)
ReDim mBytes(FileLen("C:\test.xls"))
FileToUpload = File.OpenRead("C:\test.xls")
q = FileToUpload.Read(mBytes, 0, FileLen("C:\test.xls"))
'Trying to upload here, not sure what the 16384 refers to.
intTmp = 16384
Do While k < mBytes.Length
If mBytes.Length - k < 16384 Then
intTmp = mBytes.Length - k
End If
FileMemory.Write(mBytes, k, intTmp)
FileMemory.WriteTo(mDataStream)
k += intTmp
System.Console.Out.WriteLine(k)
Loop
mDataStream.Close()
uploadPort.Close()
Any help would be greatly appreciated.