I just want to upload a .dat file from a windows phone to a php script.
This is my code, but doesn't work. Can anyone see a reason why?
C#:
string fileBase64 = "UklGRt4lAABXQVZFZm10IBAAAAABAAEARKw...";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://...mysite.../upload.php");
request.Method = "POST";
request.ContentType = "application/octet-stream";
string postData = String.Format("file={0}", fileBase64);   
// Getting the request stream.
request.BeginGetRequestStream
    (result =>
    {
        // Sending the request.
        using (var requestStream = request.EndGetRequestStream(result))
        {
            using (StreamWriter writer = new StreamWriter(requestStream))
            {
                writer.Write(postData);
                writer.Flush();
            }
        }
        // Getting the response.
        request.BeginGetResponse(responseResult =>
        {
            var webResponse = request.EndGetResponse(responseResult);
            using (var responseStream = webResponse.GetResponseStream())
            {
                using (var streamReader = new StreamReader(responseStream))
                {
                    string srresult = streamReader.ReadToEnd();
                }
            }
        }, null);
    }, null);
PHP:
    define("UPLOAD_DIR", "./uploads/");
    if(isset($_POST['file']))
    {
        $base64_string = $_POST['file'];
        $ifp = fopen( UPLOAD_DIR.'aaa.dat', "wb" ); 
        fwrite( $ifp, base64_decode($base64_string) ); 
        fclose( $ifp ); 
        echo "ok";
        echo $base64_string;
        echo base64_decode($base64_string);
    }else{
            echo "no submit";
        }
 
     
     
    