Hello
I want to implement file transfer in a bunch of C # and PHP.
Client-side function:
And this is how the server-side receive function is implemented.
The problem is that there are no errors in the transfer ($ _FILES ['file'] ['error'] returns 0), but I still can't see the file on the server.
The uploads folder with permissions 777, $ _FILES ['file'] ['name'] inside stores the correct file name, file transfer in PHP is enabled.
if (move_uploaded_file ()) fails altogether.
1. What is the error of receiving the file?
2. If I want to convey something other than text - how to implement it? The option is that if we transfer a text file, then we send the argument "text / plain" to the function; use a different MIME-type for the picture, but this is somehow bad from the point of view of the code.
I want to implement file transfer in a bunch of C # and PHP.
Client-side function:
Client:
public void Upload()
{
string uriString = "http://127.0.0.1/upload.php";
WebClient myWebClient = new WebClient();
myWebClient.Headers.Add("Content-Type", "text/plain");
myWebClient.UploadFile(uriString, "POST", @"С:\test.txt");
}
Server:
$upload_dir = "/var/html/www/uploads/";
$upload_file = $upload_dir . $_FILES['file']['name'];
$tmp_name = $_FILES['file']['tmp_name'];
move_uploaded_file($tmp_name, $upload_file);
The uploads folder with permissions 777, $ _FILES ['file'] ['name'] inside stores the correct file name, file transfer in PHP is enabled.
if (move_uploaded_file ()) fails altogether.
1. What is the error of receiving the file?
2. If I want to convey something other than text - how to implement it? The option is that if we transfer a text file, then we send the argument "text / plain" to the function; use a different MIME-type for the picture, but this is somehow bad from the point of view of the code.