So the issue is the POST request is not not correct I am guessing and therefore the php is not able to read it properly.
I will post the php and c# code of request below. But I believe the main issue is the c# code of the request.. Thanks for the help.
C# Code:
string screenshot = @"C://1478941.jpg";
var request = (HttpWebRequest)WebRequest.Create("https://ADDRESS/screenshots/index.php?");
string postData = "&access_token=" + label11.Text;
postData += "&screenshot=" + screenshot;
byte[] data = Encoding.ASCII.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
using (Stream stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
string xml = new StreamReader(response.GetResponseStream()).ReadToEnd();
PHP Code:
$post_access_token = $_POST['access_token'];
$uid = $api->verifyUser($post_access_token);
if (isset($_FILES['screenshot']) && $_FILES['screenshot']['error'] != 4) {
$screenshot_file = $_FILES['screenshot'];
if(is_uploaded_file($screenshot_file['tmp_name'])){
$tokenGen = new TokenGen();
$token = $tokenGen->genToken('',40);
$screenshot_file_name = $page->sanitize($screenshot_file['name']);
$screenshot_file_name = basename($screenshot_file_name);
$file_extension = explode('.', $screenshot_file_name);
$file_extension = strtolower(end($file_extension));
$screenshot_file_name = $uid.'_'.$token.'.'.$file_extension;
$file_size = $screenshot_file['size'];
$file_tmp = $screenshot_file['tmp_name'];
$file_error = $screenshot_file['error'];
$allowed_file_extensions = 'jpg, jpeg, png, gif';
if (strpos($allowed_file_extensions,$file_extension) === false) {
$errors[] = 1;
}
if ($file_size > 3000000) {
$errors[] = 1;
}
if (!$file_error == 0) {
$errors[] = 1;
}