PHP: File_put_content 没有创建文件

PHP: File_put_content doesn't create the file

这真的很奇怪,这个php代码运行了很长时间

<?php
header('Content-type: application/json');

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
  $data = file_get_contents("php://input");
  $arr = explode(' ',trim($data));
  $file =  $arr[0];
  $my_file = "bet_shared/".$file;
  $sharing_bet = strstr($data," ");
  file_put_contents($my_file, $sharing_bet);
}
else
{
    var_export($_SERVER['REQUEST_METHOD']);
}
?>

现在方法 file_put_contents($my_file, $sharing_bet) 不会在 bet_shared 目录中创建文件。文件夹和目录中的所有权限都设置为 777 所以其他问题对我来说没用!我错过了什么吗?

最后整理出来: 该脚本是从 android 应用程序调用的,这是我用来创建连接的 java 代码和 POST 一些字符串

 URL url = new URL(URL_STRING);
                HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
                conn.setConnectTimeout(CONNECTION_TIMEOUT);
                conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
                //conn.setDoOutput(true);
                conn.setDoInput(true);
                conn.setUseCaches(false);
                conn.setRequestMethod("POST");
                conn.connect();

                OutputStream os = conn.getOutputStream();
                os.write(jsonBet.getBytes("UTF-8"));
                os.close();

我在下面添加了这段代码:

                if (200 <= conn.getResponseCode() && conn.getResponseCode() <= 299) {
                    BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                    Log.i("response = " , br.readLine());
                } else {
                    BufferedReader br = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
                    Log.i("response two = " , br.readLine());

                }

好像没有设置响应代码连接就断开了