Solved

VB INET - PUT FILE TO SUBFOLDER ON FTP SITE

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 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

16 Experts available now in Live!

Get 1:1 Help Now