ItsMods

Full Version: Upload files to FTP server
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Sending files to an FTP server, you can use your PC to send logs to a computer with the VPS.
PHP Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
using Addon;

namespace 
FTP
{
    public class 
Class1 CPlugin
    
{
        public 
override void OnServerLoad()
        {
            var 
filename "plugins//log.txt";
            
string ftpServerIP "127.0.0.1";
            
string ftpUserID "admin";
            
string ftpPassword "12345";
            
string ftpPath "/public_html/";
            
FileInfo fileInf = new FileInfo(filename);
            
string uri "ftp://" ftpServerIP ftpPath fileInf.Name;
            
FtpWebRequest reqFTP;
            
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" ftpServerIP ftpPath fileInf.Name));
            
reqFTP.Credentials = new NetworkCredential(ftpUserIDftpPassword);
            
reqFTP.KeepAlive false;
            
reqFTP.Method WebRequestMethods.Ftp.UploadFile;
            
reqFTP.UseBinary true;
            
reqFTP.ContentLength fileInf.Length;
            
int buffLength 2048;
            
byte[] buff = new byte[buffLength];
            
int contentLen;
            
FileStream fs fileInf.OpenRead();
            try
            {
                
Stream strm reqFTP.GetRequestStream();
                
contentLen fs.Read(buff0buffLength);
                while (
contentLen != 0)
                {
                    
strm.Write(buff0contentLen);
                    
contentLen fs.Read(buff0buffLength);
                }
                
strm.Close();
                
fs.Close();
            }
            catch (
Exception ex)
            {
                
ServerPrint("[FTP Status]: " ex.Message);
            }
        }
    }

(01-27-2016, 20:17)S3VDIT0 Wrote: [ -> ]I think everyone realized Why is it necessary

I don't.
(01-28-2016, 09:03)SuperNovaAO Wrote: [ -> ]
(01-27-2016, 20:17)S3VDIT0 Wrote: [ -> ]I think everyone realized Why is it necessary

I don't.

Oh sorry =)
I'm in a hurry and could not explain.
This script I made of the need to send server logs to my FTP server, just when I am on the VPS I dig into folders server lag, as well as my PC quickly send logs or complaints about the players...

zhorakrnev

?
(01-28-2016, 16:50)zhorakrnev Wrote: [ -> ]?

, VPS , , ! FTP ( FTP ) , =)