Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Upload Files to Web...

Posted on 2003-11-04
11
Medium Priority
?
218 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 500 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
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.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

730 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