Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.5K
Views
How to send big files from URL to Telegram bot?

I have some big size files (in MP4 and Zip formats) and I want to send them to my chat by Telegram bot, I used the code below:

file_get_contents('https://api.telegram.org/bot[[app:token]]/sendDocument?chat_id=24523586&document='.$fileAddress);

But it just can send files with small sizes, less than 50MB! But I know there is no file size limitation for documents which are sending by file_id. You can see this page
Now how can I make file_id for my files? My files are uploaded on my server and I am using PHP.

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Telegram bot API can only send files less than 20 MB by url param, you should lookup Sending Files section.

If you want to send 20-50 MB files, you should download and re-upload to Telegram bot API server.
You can refer this simple code

$curl = curl_init();
curl_setopt_array($curl, [
    CURLOPT_URL => 'https://api.telegram.org/bot131210513:AXXXXXX/sendDocument?caption=Hello+World&chat_id=24523586',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: multipart/form-data'
    ],
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => [
        'document' => curl_file_create('/etc/hosts', 'plain/text', 'Hosts-file.txt')
    ]
]);
$data = curl_exec($curl);
curl_close($curl);
about 4 years ago · Santiago Trujillo Report

0

2021 Update: Telegram now provides a self hostable Telegram Bot API which can upload 1.5GB.

You can install pwrtelegram on your server. Then simply switch the API URL and you will be able to upload up to 1.5 GB of files with your bot. That is the only possible way. Check out the link for more information.

Also, you cannot pass in any random file_id, as Telegram will not send it. You can only pass in a file_id which has been uploaded by your bot previously. To bypass the limit, use the method, above. It works very well.

about 4 years ago · Santiago Trujillo Report

0

Firstly you should send your file(s) to your bot and then get the fileID.

After that you can just use the fileID to send your files and this way the load will be on Telegram's server not yours. Of course you can send the files from your own server to but this method will cause speed reduction for your bot.

Note that when you send a file to your bot and get the fileID, from that moment the file can be sent immediately without needing to store the files on your own server.

You don't need to make a fileID.

All you need is sending the file to the bot and let the bot find out the fileID and save it somewhere for future transfers.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!