Object creation is not working for docx (word) file document using M-Files API endpoint

Hello,

I'm trying to build a simple program using PHP to create a new object within an attachment file included inside the object (docx) but always return corrupt / unreadable. But it is working well for PDF attachment file.

Code snippet :

                       

                       $base_url = 'http://localhost/REST';               
                       $obj_type_id = 0; //0 : document, 1 : other document
                       $headers = [
                             'X-Authentication: ' . $access_token,
                             'Content-Type: application/json',
                       ];
                        //Uploading file to M-Files temp folder
                        $content = file_get_contents($file_transfer_path);

                        curl_setopt($ch, CURLOPT_URL, $base_url . '/files.aspx');
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                        curl_setopt($ch, CURLOPT_POST, true);
                        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                        curl_setopt($ch, CURLOPT_POSTFIELDS, ['file' => $content]);

                        $uploadFileResponse = curl_exec($ch);
                     
                        $uploadInfo = json_decode($uploadFileResponse, true);

                        $uploadInfo['Extension'] = pathinfo($file_transfer_path, PATHINFO_EXTENSION);
                        $uploadInfo['Title'] = pathinfo($file_transfer_path, PATHINFO_FILENAME);

                        $file_data = [
                            'Files' => [[
                                "UploadID" => $uploadInfo['UploadID'],
                                "Title" => $uploadInfo['Title'],
                                "Extension" => $uploadInfo['Extension'],
                                "Size" => $uploadInfo['Size'],
                            ]],
                        ];

                        $post_data = array_merge($new_object_data, $file_data);

                        //Creating new object within content file
                        curl_setopt($ch, CURLOPT_URL, $base_url . "/objects" . "/" . $obj_type_id . '.aspx');
                        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));

                        $createObjectResponse = curl_exec($ch);

                        echo "createObjectResponse : " . $createObjectResponse . "<br><br>";
Please kindly guide if you feel my code will fail.
Regards
Indri