Results 1 to 9 of 9

Thread: confused in file paths

  1. #1

    Thread Starter
    Hyperactive Member Rattled_Cage's Avatar
    Join Date
    Dec 2005
    Posts
    315

    confused in file paths

    this first routine sets the file names from the commmon diaglog box

    and then uploads just fine

    what i want to do is click a file2 box and upload that file

    but i cant seem to get the strings right to do so and am confused

    can anyone see where im going wrong ?>

    Code:
     
    Private Sub cmdUpload_Click()
    Dim lTimer As Long
    Dim strRemote As String
    mWait
    cd.ShowOpen
    File_To_Upload.Caption = Trim(cd.FileTitle) ''sets captions from common diag
    File_To_Upload_Path.Caption = Trim(cd.Filename)
    strRemote = Trim(File_To_Upload.Caption)
    pb.Visible = True
    lTimer = timer
    If strRemote <> "" Then
    If Not mFTP.FTPUploadFile(Trim(File_To_Upload.Caption), Trim(File_To_Upload.Caption)) Then
    Console.text = ""
    Console.text = Console.text & Trim(File_To_Upload.Caption) & mFTP.GetLastErrorMessage & vbCrLf
    Console.text = Console.text & ">" & vbCrLf
    Else
    Console.text = ""
    Console.text = Console.text & "Upload" & Trim(File_To_Upload.Caption) & " complete in " & Format(timer - lTimer, "###,##0.00") & " seconds." & vbCrLf
    Console.text = Console.text & ">" & vbCrLf
    End If
    End If
    pb.Visible = False
    mOk
    RefreshDirectoryListing
    End Sub
    doesnt work but the paths and file names look the same as what the first routine does

    Code:
    Private Sub File2_Click()
    File_To_Upload.Caption = File2.Filename
    File_To_Upload_Path.Caption = App.Path & "\Incoming_Files\" & File2.Filename
    Dim lTimer As Long
    Dim strRemote As String
    strRemote = Trim(File_To_Upload.Caption)
    pb.Visible = True
    lTimer = timer
    If strRemote <> "" Then
    If Not mFTP.FTPUploadFile(Trim(File_To_Upload.Caption), Trim(File_To_Upload.Caption)) Then
    Console.text = ""
    Console.text = Console.text & Trim(File_To_Upload.Caption) & mFTP.GetLastErrorMessage & vbCrLf
    Console.text = Console.text & ">" & vbCrLf
    Else
    Console.text = ""
    Console.text = Console.text & "Upload" & Trim(File_To_Upload.Caption) & " complete in " & Format(timer - lTimer, "###,##0.00") & " seconds." & vbCrLf
    Console.text = Console.text & ">" & vbCrLf
    End If
    End If
    pb.Visible = False
    RefreshDirectoryListing
    End Sub

  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: confused in file paths

    What you get and what is should be?

    What about replacing
    Code:
    File_To_Upload_Path.Caption = App.Path & "\Incoming_Files\" & File2.Filename
    with
    Code:
    File_To_Upload_Path.Caption = File2.Path & "\" & File2.Filename



  3. #3

    Thread Starter
    Hyperactive Member Rattled_Cage's Avatar
    Join Date
    Dec 2005
    Posts
    315

    Re: confused in file paths

    hi 4x2 : )
    that still comes back with invalid index error

    ive uploaded the project
    im not sure if you have an ftp upload folder to test it with
    Attached Files Attached Files

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: confused in file paths

    If you are getting an invalid index error that seems a bit odd as I see nothing that uses an index. Other than maybe the file list box?

    What line is throwing the error?

    Is there a file selected in the file list box at the time?

  5. #5

    Thread Starter
    Hyperactive Member Rattled_Cage's Avatar
    Join Date
    Dec 2005
    Posts
    315

    Re: confused in file paths

    the strange thing is here
    if i select a file from out the incoming folder and send it using comondiag it sends ok
    then if you send a second file by clicking the filebox it send that file though ok

    it comes back with an error invalid prop value if you click the filebox fiirst though

    pb.Max = lTotalBytes

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: confused in file paths

    I do not see that line in the code you have posted,

    best guess is that your total bytes var has not been assigned a value at that time.

  7. #7
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: confused in file paths

    I downloaded your project. I didn't get any errors nor did I look for any missing information that should have displayed but I did find a problem in two of your functions or at least it was a problem for me:

    Code:
    Private Sub cmdUpload_Click()
    Dim lTimer As Long
    Dim strRemote As String
    
    cd.ShowOpen
    File_To_Upload.Caption = Trim(cd.FileTitle) ''sets captions from common diag
    File_To_Upload_Path.Caption = Trim(cd.Filename)
    strRemote = Trim(File_To_Upload.Caption)
    pb.Visible = True
    lTimer = Timer
    If strRemote <> "" Then
    
    'Only contains file name----------------+
    'If Not mFTP.FTPUploadFile(Trim(File_To_Upload.Caption), Trim(File_To_Upload.Caption)) Then
    
    '
    'This only contains the file name but should be full path ---------+
    If Not mFTP.FTPUploadFile(Trim(File_To_Upload_Path.Caption), Trim(File_To_Upload.Caption)) Then
      '
      '
      '
    End Sub
    
    Public Function FTPUploadFile(sLocal As String, sRemote As String) As Boolean
        Dim Data(BUFFERSIZE - 1) As Byte
        Dim Written As Long
        Dim Size As Long
        Dim Sum As Long
        Dim lBlock As Long
        
        Sum = 0
        lBlock = 0
    
        sLocal = Trim(sLocal)
        
        'Note: I had to add the full path to the directory where I wanted to upload to since 
        'sRemote only containd the file name but should have the full path. 
        'See note at above Sub 
        sRemote = "/<--- full file path --->/" & Trim(sRemote)
        '
        '
        ' 
    End Function
    I had to add the bold red otherwise it would not upload.
    Last edited by jmsrickland; Aug 14th, 2015 at 08:22 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  8. #8

    Thread Starter
    Hyperactive Member Rattled_Cage's Avatar
    Join Date
    Dec 2005
    Posts
    315

    Re: confused in file paths

    @jmsrickland i changed to your code
    Code:
    If Not mFTP.FTPUploadFile(Trim(File_To_Upload_Path.Caption), Trim(File_To_Upload.Caption)) Then
    and it works when you click the file1 list now : ) thanks

    i didnt change the sRemote though .....
    just as a closing point what Os did you test this on
    im on xp pro 64 bit and not sure how it works with all the various os`s out there

  9. #9
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: confused in file paths

    I'm on XP Pro/SP2 32 Bit

    If this app is for you only then you may not need to change sRemote but if other people who have different sites are going to use it you will need to take in account the directory structure of other sites as they vary from one to another.

    Example: on my site it has to be "/root/web name/primary directory/" & sRemote and on another site of mine it's totally different


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width