Connect to FTP, retrieve txt file contents?

Discussion in 'Plugin Development' started by KraZ__, Nov 16, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    KraZ__

    Hello, I've made a basic log plugin which stores data into a text file, and I want to retrieve this text file from my web hosting server and display the log on the website? how can I do this using PHP or JavaScript?

    Can someone help! Would be much appreciated!
     
  2. Offline

    Bart

    Hey Kraz__,

    You won't be able to do this unless you create some FTP server on the Bukkit server (This would be completely redundant). One way to do it would be via SSH however I would recommend making the plugin push the log file to the website every X mins - from there you can access it normally via PHP.

    Thanks,
    Bart
     
  3. Offline

    KraZ__


    Thanks for the help! But surely I could connect to a hosted FTP server and retrieve the file there?

    If not, how would I push the file to the web server every so often?
     
  4. Offline

    Bart

    The website could retrieve the file from an FTP server however you would then have to make the FTP server on the Minecraft server which isn't great.. I would do what I told you to do in my previous post.

    There's a tutorial by TheBcBroz on YouTube which shows a good FTP client tutorial for use in the plugin to upload a log file every now and again for the website to grab.
     
  5. Offline

    KraZ__


    Thank you very much Bart, much appreciated.
     
  6. Offline

    Bart

    No problem. PM me if you need help with sorting out code (please make sure you give it a go first!)
     
  7. Offline

    frostalf

    You would not need to create an FTP server on bukkit server to do this. All one needs is basic FTP protocol usage which you don't need to have a server for. You can go about it 3 ideal ways KraZ__. The first way is to make use of the FTP protocol in your plugin which is what your wanting. Take a look at using org.apache.commons.net.ftp

    http://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/ftp/package-summary.html

    The second way is, setting a cron job to rysync over ftp to your webhost where then the website code can take over from there.

    The third way you can do this, run an ftp server, set where the log is at accessible via ftp account, let the PHP code on website retrieve the file.



    For the way your wanting to do it, Bart is correct. You would need an FTP server, the best way would be to have the plugin push the file to webhost instead of the webhost retrieving the file.
     
  8. Offline

    Bart

    I didn't say you needed an FTP server to push a file to a webserver.
     
  9. Offline

    frostalf

    Sorry Bart mis-read what you said, edited my post to reflect that
     
Thread Status:
Not open for further replies.

Share This Page