Solved

Upload Files to Web...

Posted on 2003-11-04
11
213 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
  • 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
LVL 5

Expert Comment

by:fantasy1001
ID: 9691401
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

792 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