Solved

VB INET - PUT FILE TO SUBFOLDER ON FTP SITE

Posted on 2006-11-21
7
1,516 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

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.

Question has a verified solution.

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

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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.
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…

821 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