Solved

VB INET - PUT FILE TO SUBFOLDER ON FTP SITE

Posted on 2006-11-21
7
1,508 Views
Last Modified: 2012-05-05
I have an ftp script which is working, but does not allow me to place a file in a subfolder of the FTP site. I have tried various methods but none seem to function. I basically have a subfolder called IN within the ftp main folder which i need to save a file to. Any assistance would be appreciated. I have tried adding  - & "/IN/" - to the host_name, but this is ignored and the file is saved in the root directory. My code is below.

Private Function UploadFile(ByVal source_file As String, _
    ByVal dest_file As String, ByVal host_name As String, _
    ByVal user_name As String, ByVal passwd As String) As _
    Boolean
   

    On Error GoTo UploadError


    If LCase$(Left$(host_name, 6)) <> "ftp://" Then _
        host_name = "ftp://" & host_name
       

     InetFTP.URL = host_name
     InetFTP.UserName = user_name
     InetFTP.Password = passwd


    InetFTP.Execute , "Put " & source_file & " " & dest_file
   
     
    UploadFile = True
    Exit Function

UploadError:
    MsgBox "Error " & Err.Number & _
        " uploading file '" & _
        source_file & "' to '" & _
        dest_file & "'." & vbCrLf & Err.Description, _
        vbExclamation Or vbOKOnly, _
        "Download Error"
    UploadFile = False
    Exit Function
End Function
0
Comment
Question by:WMfxms
7 Comments
 
LVL 20

Expert Comment

by:hes
ID: 17990215
Try
InetFTP.Execute , "CD IN"  before your put
0
 

Author Comment

by:WMfxms
ID: 17990574
I get still executing last request error
0
 

Author Comment

by:WMfxms
ID: 17990680
placing - & "IN\" - before - & dest_file- did the job...

Seems like a bit of a schoolboy error really... :)

0
 
LVL 4

Expert Comment

by:JRCSystems
ID: 17992608
I am not positive, BUT, here's a thought...

Microsoft, in its Infinite wisdom in the Implementation of the INET control, and PUT and GET commands...
Well, basically, they DONT WORK if the source or destination have SPACES in the file names because the SPACE is a delimiter in the GET/PUT syntax...

So, cheat.

If your source file has a space in it, copy it to a temp area into a filename without spaces.
Your destination name cannot have a space in it either.

As far as specifying the folder name in the destination, that works just fine, I'd suggest the "/" forward slash.

Hope that helps.
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 18449444
PAQed with points refunded (500)

DarthMod
Community Support Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

930 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now