Solved

VB INET - PUT FILE TO SUBFOLDER ON FTP SITE

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 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…

786 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