Solved

Upload Files to Web...

Posted on 2003-11-04
11
216 Views
Last Modified: 2010-05-03
I've got an application I'm writing in visual studio for web-management purposes. The application is part of a larger application we have created with seperate sections for each of the day-to-day operations here at my company. The particular section I'm working on is for image additions, deletions, and replacement on our database driven website. Everything works fine other than the function to upload images to the FTP server. I have very limited knowledge on FTP and I don't need all the functionality of an FTP client. I simply want to be able to upload one image at a time to the server. I don't have a whole lot of points to offer, so I offered what I could afford. Any help will be greatly appreciated.
0
Comment
Question by:JimHERBEAU
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
11 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9681609
0
 
LVL 5

Accepted Solution

by:
fantasy1001 earned 125 total points
ID: 9683526
Add a component named Microsoft Internet Transfer Control to your form,
Then

  Inet1.RemoteHost = "ftp://www.duck.org"
  Inet1.URL = "ftp://www.duck.org/
  Inet1.UserName = "LoginName"
  Inet1.Password = "password"
  Inet1.Protocol = icFTP
  Inet1.Execute "ftp://www.duck.org/">ftp://www.duck.org/", _
    "PUT C:\TestFile.txt TestFile.txt"

~ fantasy ~
0
 

Author Comment

by:JimHERBEAU
ID: 9687137
Whats the actual component file name (I.E. msitp.dll)? I can't find one that has the description name you gave.
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9687283
Do a right click on toolbox and choose add...
Locate Microsoft Internet Transfer control
0
 

Author Comment

by:JimHERBEAU
ID: 9687371
I'm using Visual Studio 2002 with VB.net and couldn't find that control anywhere, nor anyone who claims it's in any version of VB past VB 6.0
Thanks for the help though.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 9687447
At least, all solutions posted here were for VB6 not .net!!!!
There is a .Net TA here, at EE, look at it.
0
 

Author Comment

by:JimHERBEAU
ID: 9694109
I got it working playing around with some of the other components in VS

  Private mNetStream As NetworkStream
    Private mBytes() As Byte

    Public Function FtpCommand(ByVal strCommand As String) As String
        If mConnected Then
            Try
                Erase mBytes
                RaiseEvent ServerCalled(strCommand & vbCrLf)
                mBytes = Encoding.ASCII.GetBytes(strCommand & vbCrLf)
                mNetStream.Write(mBytes, 0, mBytes.Length)
                FtpCommand = GetResponse()
            Catch err As Exception
                RaiseEvent ErrorOccured(EC.FTPCommandFailed, err.ToString())
            End Try
        End If
    End Function

    Private Function OtherPortPut(ByVal intDataPort As Int32, ByVal strFN As String, Optional ByVal BytesWillRec As Int64 = 0) As MemoryStream
        Dim strTemp As String
        Dim i As Int64
        Dim priSM As New MemoryStream()
        Dim priSM1 As FileStream
        Dim intTmp As Integer

        If BytesWillRec >= 0 Then
            Try
                ReDim mBytes(FileLen(strFN))

                priSM1 = File.OpenRead(strFN)
                intBytesRec = priSM1.Read(mBytes, 0, FileLen(strFN))
                priSM.Write(mBytes, 0, mBytes.Length - 1)
                priSM.WriteTo(mDataStream)


                mDataStream.Close()
                OtherPortPut = priSM
                mTCPData.Close()
            Catch err As Exception
                RaiseEvent ErrorOccured(EC.UploadFailed, err.ToString())
            End Try
        Else
            RaiseEvent ErrorOccured(EC.InvalidFileLength, "Invalid declared file length!")
        End If
    End Function

  Public Function FtpPutFile(ByVal strFile As String, ByVal strDest As String, ByVal intSize As Long) As MemoryStream
        Dim priSM As New MemoryStream()
        Dim strTemp As String
        Dim i, j As Int16
        Dim intPort As Int32

        If mConnected Then
            Try
                strTemp = FtpCommand("TYPE I")
                intPort = cmdPasv2Port()
                strTemp = FtpCommand("STOR " & strDest)
                i = mFTPResponse.LastIndexOf(")", mFTPResponse.Length - 1)
                j = mFTPResponse.LastIndexOf("(", i)
                i = mFTPResponse.IndexOf(" ", j)
                strTemp = mFTPResponse.Substring(j + 1, i - j - 1)

                priSM = OtherPortPut(intPort, strFile, intSize)
                FtpPutFile = priSM

                strTemp = GetResponse()
                If strTemp.Substring(0, 4) <> "226 " Then
                    RaiseEvent ErrorOccured(EC.DownUpLoadFailure, "Transfer failure!")
                End If
            Catch err As Exception
                RaiseEvent ErrorOccured(EC.FTPPutFileFailed, err.ToString())
            End Try
        End If
    End Function
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month3 days, 21 hours left to enroll

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question