|
-
Mar 25th, 2000, 04:59 AM
#1
Thread Starter
Lively Member
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.
-
Mar 25th, 2000, 11:50 AM
#2
Lively Member
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
-
Mar 26th, 2000, 01:50 AM
#3
Thread Starter
Lively Member
duh
DUH! Why didn't I think of that.. THANKS MAN
-
Mar 26th, 2000, 05:08 PM
#4
"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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|