Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2008
    Location
    UK
    Posts
    6

    Simple FTP check: Not a newbie but no expert either.

    Hello,

    I would like a simple file upload system where the user:
    clicks on the "choose a file to upload button"
    selects a file and clicks submit button.
    The file is uploaded to my server via ftp.

    Once the user has selected a file I would like them to have the option of either changing their mind and choose another file if they make a mistake or clicking on submit.



    I can configure the ftp using the plugin but am stuck on how to check whether a file has been selected or not so if no file has been selected the user cannot submit.

    I am also struggling to find a decent progress bar, so when the upload is complete the page jumps to another. (files around 50 to 100mb)


    My code is as follows for:



    "choose a file to upload" button (on_click code)
    ----------------------------------------------------

    -- defines for table and text file if a file is selected
    string_uploader = "abletoupload";
    my_uptable = {string_uploader};

    --open browser and select file to upload
    archive_files = Dialog.FileBrowse(true, "Files to Add", _DesktopFolder, "All Files (*.*)|*.*|", "", "dat", false, false);

    -- Check to see if an error occurred, or the user cancelled.
    if (archive_files[1] ~= "CANCEL") and (archive_files ~= nil) then

    -- create a text file if a file is selected
    TextFile.WriteFromTable("AutoPlay\\Docs\\upload.tx t", my_uptable, false);
    end



    --these are for keeping the files the same names and extensions

    tFile = String.SplitPath(archive_files[1]);
    sName = (tFile.Filename);
    sExt = (tFile.Extension);
    sFileName = String.Concat(sName,sExt);




    "submit" button (on_click code)
    ------------------------------------------------------

    -- Checks to see if a particular file exists.
    are_ya_there = File.DoesExist("AutoPlay\\Docs\\upload.txt");

    -- If the file does not exist, display a message notifying the user.
    if are_ya_there == false then
    result = Dialog.Message("Notice", "Please choose a file to upload", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
    else
    FTP.Upload(archive_files[1], sFileName, nil)
    end



    So the strategy was to create a text file "upload.txt" once the user has selected a file and then check that this text file exists when clicking on the submit button to allow the upload. Does not work, the text file is never created (admin rights are full for vista)

    The progress bar is a mystery at the moment.

    Would appreciate any help.

    Rob

  2. #2
    Join Date
    Oct 2009
    Location
    127.0.0.1
    Posts
    279
    Here is a very simple FTP example. There are other more advanced examples on the forum if you need to get more in depth. You don't need to write to a text file, this will upload multiple files selected at once. You can use a listbox to add the files to for the user to see the files selected. Hope this helps.
    Attached Files
    There are 10 types of people in the world: those who understand binary, and those who don't.

Posting Permissions

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