The following C# code is used to upload the json file (~3.6 MB) to the server. Here, I am using WebClient to upload file to the server.
private void btnUploadToServer_Click(object sender, EventArgs e)
{
try
{
using (WebClient client = new WebClient())
{
string filePath = @"C:\Users\SAKTHY-PC\Desktop\app_erp_suneka.json";
var serverPath = new Uri(@"http://example.com/newSync/upload.php");
client.UploadFile(myUri,filePath);
}
Application.Exit();
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
}
And I have a php script file (upload.php
) in the following folder http://example.com/newSync/
<?php
$filepath = $_FILES["file"]["tmp_name"];
move_uploaded_file($filepath,"app_erp_suneka.json");
?>
The problem is unable to upload 2MB or more than 2MB file to the server. But less than 2MB file is successfully uploaded.