예제 #1
0
        /// <summary>
        /// Uploads the specified file and stores it on the server.
        /// </summary>
        /// <param name="fileLocation">The file path to the file that is being uploaded.</param>
        /// <param name="submitAct"></param>
        public static void UploadFile(string fileLocation, string submitAct, string programid = null)
        {
            try
            {
                using (ByteGuardWebClient byteguardWebClient = new ByteGuardWebClient())
                {
                    byteguardWebClient.Headers.Add("Content-Type", "binary/octet-stream");
                    byteguardWebClient.CookieJar = CookieContainer;

                    lock (LockObject)
                    {
                        Variables.WebResponse = Encoding.ASCII.GetString(byteguardWebClient.UploadFile(String.Format("{0}files/upload.php?type={1}&pid={2}", Variables.ByteGuardHost, submitAct, programid), "POST", fileLocation));
                    }
                }
            }
            catch
            {
                Variables.Containers.Main.SetStatus("Failed to upload file, please try again shortly.", 1);
            }
        }