Results 1 to 4 of 4

Thread: FTP Push / Long File Names

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    flanders, nj 07836
    Posts
    110
    Wazzz-sup fellow progy's. Here's a good one for yah.
    Wrote a program that needs to push JPG's up to an ftp server, whichever one they pick in a commondialog open file window.
    Basically they pick the file, then I kick in the inet.execute like this.....
    INET.execute , "PUT " & filename & " /"& username & ".jpg"
    (username is just a global in the program and filename is a text box) ..
    It works .. EXCEPT if they browse to directory that contain spaces. IE MY PROGRAMS.. because what happens is the follow command gets sent to the ftpserver
    "PUT C:\MY PROGRAMS\ME.JPG /ME.JPG"
    Well this confuses the ftp server and it trys to send C:\MY and put it on the server as PROGRAMS\ME.JPG .. You get the drift. Are there any function /procedures that anyone knows of that will turn a 32bit long name into the 16bit short name (8.3 format) ? If not.. any other ideas on how to upload to an ftp server? Thanks guys.

  2. #2
    Lively Member
    Join Date
    Nov 1999
    Location
    Melbourne, Victoria, Australia
    Posts
    126

    FTPFilename = ""

    For x = 1 to Len(filename)

    Char = Mid(filename,x,1)

    if Char = " " Then
    FTPFilename = FTPFilname & "%20"
    else
    FTPFilename = FTPFilname & Char
    end if
    next x

    FullCmd = PUT " & FTPFilename & " /"& username & ".jpg"

    Inet1.Execute FullCmd


    [Edited by privoli on 03-25-2000 at 11:51 PM]
    Regards,

    Paul Rivoli
    ---------------------
    [email protected]
    http://members.dingoblue.net.au/~privoli

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Location
    flanders, nj 07836
    Posts
    110

    duh

    DUH! Why didn't I think of that.. THANKS MAN

  4. #4
    Guest
    "PUT ""C:\MY PROGRAMS\ME.JPG"" /ME.JPG" should also work

    Or you could convert it to a short path:
    Code:
    Option Explicit
    Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
    Private Const MAX_PATH As Long = 260
    
    Private Function GetShortPath(sLongPath As String) As String
        Dim sBuffer As String
        Dim lRet As Long
        sBuffer = Space$(MAX_PATH)
        lRet = GetShortPathName(sLongPath, sBuffer, MAX_PATH)
        sBuffer = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1)
    End Function
    
    Private Sub Command1_Click()
        MsgBox GetShortPath("C:\Program Files")
    End Sub

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