我正在嘗試發(fā)送一個(gè) xls 文件。上網(wǎng)查了2個(gè)小時(shí),也沒搞清楚哪里出錯(cuò)了。我正在嘗試從 url 發(fā)送此文件。這是我的代碼$filePath = $dburl."Last_season.xls";$document = new CURLFile($filePath);$post = array('chat_id' => $callback_id_username,'document'=> $document,'caption' => $caption);$ch = curl_init();curl_setopt($ch, CURLOPT_URL,$GLOBALS[website]."/sendDocument");curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post);$result_curl = curl_exec ($ch);curl_close ($ch);
1 回答
躍然一笑
TA貢獻(xiàn)1826條經(jīng)驗(yàn) 獲得超6個(gè)贊
目前不支持通過 url 發(fā)送 xls 文件。
通過 URL 發(fā)送- 在 sendDocument 中,通過 URL 發(fā)送目前僅適用于gif、pdf和zip文件。
要解決此問題,您可以先將 xls 文件存儲(chǔ)在您的系統(tǒng)上并使用此文件 - 而不是 url。
一種方法是:
$url_of_file = $dburl."Last_season.xls";
$file_name = basename($url_of_file);
file_put_contents( $file_name,file_get_contents($file_name)); //store xls file named "Last_season.xls" locally
$document = new CURLFile($file_name);
$post_data = ["chat_id" => ADMIN_CHAT_ID, "document" => $document];
- 1 回答
- 0 關(guān)注
- 213 瀏覽
添加回答
舉報(bào)
0/150
提交
取消
