Announcement

Collapse
No announcement yet.

FTP upload never completes.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • FTP upload never completes.

    It's a long time since I used AMS but having some time on my hands I decided to come back to an old project to upload an image from my IP camera to my webspace with a name that I could then include in a static page. I'm almost there but after connecting to the FTP server it all works until the upload starts. It stops working and leaves the file correctly named but only 255 bytes in size. The upload finally throws an error message "Chunk: has too many syntax levels".

    The whole thing as it stands - Button on click works perfectly:-

    Code:
    -- check if previous file still there and if so delete
    result = File.DoesExist("C:\\Users\\George\\Desktop\\grab.jpg");
    if result then
    File.Delete("C:\\Users\\George\\Desktop\\grab.jpg", false, false, false, nil);
    end
    
    HTTP.Download("http://MYUSERNAME:[email protected]/cgi-bin/snapshot.cgi", "C:\\Users\\George\\Desktop\\grab.jpg", MODE_BINARY, 20, 80, nil, nil, nil);
    grabbed=true
    
    Page.StartTimer(1000, 10);

    Page on timer event where the problem lies:-

    Code:
    -- belt and braces just double check that the image was grabbed
    if grabbed == true then
    FTP.Connect("ftp server URL", "MyUserName", "My Account Name", "My Account Name", false);
    -- turn passive mode on
    FTP.SetPassiveMode(false);
    FTP.ChangeDir("/htdocs/");
    StatusDlg.Show(MB_ICONNONE, false);
    FTP.Upload("C:\\Users\\George\\Desktop\\grab.jpg", "grab.jpg", nil);
    StatusDlg.Hide();
    grabbed = false
    FTP.Disconnect()
    end
    
    -- delete the image from desktop
    result = File.DoesExist("C:\\Users\\George\\Desktop\\grab.jpg");
    if result then
    File.Delete("C:\\Users\\George\\Desktop\\grab.jpg", false, false, false, nil);
    end
    
    if grabbed == false then
    Application.Exit();
    end
    I've tried both true and false for passive mode.

  • #2
    Well for one your timer is not wrapped in it's timer id so no matter what this timer is always going to be triggered
    Plugins or Sources MokoX
    BunnyHop 2021 Here

    Comment


    • #3
      Yes point taken and I'm all for doing this the 'proper way' from the start but that's not what is causing the problem is it. Suppose I could just do it all on the button click anyway.

      Comment


      • #4
        Are you stopping the timer before connecting to the FTP server? I suspect that the one second interval is too short for your timer and are restarting the transfer over and over again, and this is why it never finishes.

        Ulrich

        Comment


        • #5
          Absolutely spot on Ulrich. Thank you very much.

          Comment

          Working...
          X