PDA

View Full Version : FTP love


Bruce
02-10-2009, 04:03 PM
Hello everyone…
Looking to make an FTP up loader for my photographers to upload video to my site. www.newsmediaservices.com

I’ll have four buttons, Picture.jpg, Movie.flv, Movie.zip and Upload files.. The script in the Picture.jpg button reads like this:

jpg_result = Dialog.FileBrowse(true, "Locate File", _DesktopFolder, "All Files (*.*)|*.*|", "", ".jpg", false, false);
Paragraph.SetText("jpg Paragraph", jpg_result[1]);

The return I get looks like this:
C:\Documents and Settings\Administrator\Desktop\G68morisita0009.jpg

What I need to show is simply G68morisita0009.jpg I know this has something to do with string trimming.

The upload button holds the following script:
Paragraph.SetText("info Paragraph", "Connecting to server...");
Connected = HTTP.TestConnection("www.google.com", 8, 80, nil, nil);
if Connected then
Paragraph.SetText("info Paragraph", "Connecting to server...");
FTP.Connect("www.mysite.com", "login", "password", "", true);

--Check to see if it's ok to gain access
FTP.ChangeDir("websites/newsmediaservices.com/docs/ok");
yes_result = FTP.GetFileInfo("peter_davidson.txt");
if yes_result == nil then
result = Dialog.Message("Notice", "You're no longer allowed to use this service. If you think this is an error, go to www.newsmediaservices.com for contact information.", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
Application.Exit(0);
end

FTP.Download("peter_davidson.txt", _TempFolder .. "\\peter_davidson.txt", nil);
--reads it into memory
yesno_result = TextFile.ReadToString(_TempFolder .. "\\peter_davidson.txt");
--then turns that into a #
aresult = String.ToNumber(yesno_result);
--deletes the text file
File.Delete(_TempFolder .. "\\peter_davidson.txt", false, false, false, nil);
if aresult == 1 then
--yes it passed

--first the .jpg
Paragraph.SetText("info Paragraph", "Changing directory...");
FTP.ChangeDir("websites/newsmediaservices.com/docs/ftp");
Paragraph.SetText("info Paragraph", "Uploading .jpg...");
FTP.Upload(jpg_result, jpg_result, nil);

HAVING AN ISSUE HERE IN RED

See any other messups let me know, thx

drgfx
02-10-2009, 04:38 PM
Running out to dinner, so don't have time to look through your code:

I've had problems with FTP uploading from a temp folder before, had to do it through AutoPlay\\Docs\\
Also: I've never used an underscore "_" in a name, dunno if that would give you a problem? jpg_result (to) jpgresult

Here is the basic code I use when ftp uploading...
hostname = "";
account = "";
password = "";
username = "";

FTP.Connect(hostname, username, password, account, true);
FTP.ChangeDir(sFolder);
FTP.Upload("AutoPlay\\Docs\\filename.zip", nil);
FTP.Disconnect();

----------------------
Dunno if any of that helps, I'm still a newbie here ;)

longedge
02-10-2009, 04:44 PM
Dialog.FileBrowse returns a table. You need to use String.SplitPath to get the filename and file extension. The help file gives some good examples.

Desrat
02-10-2009, 06:20 PM
the problem is the very last lines, replace you last line

FTP.Upload(jpg_result, jpg_result, nil);

with the following 2 lines

tblSplit = String.SplitPath(jpg_result[1]);
FTP.Upload(jpg_result[1], tblSplit.Filename .. tblSplit.Extension, nil);

Bruce
02-11-2009, 11:07 AM
Got it! Thx guys :yes