17

I need to post files up to 50 MB to Telegram bot API.

Now I'm using Curl and everything tested and passed successfully. It means that I can only send small files (I couldn't send 8. 1 MB file in my test). So if I send large files (lets say more than 8 MB) all $_POST variables are empty, meaning nothing posted.

Question: Is there any limitation in sending file using curl? Because I asked my server administrator to increase related configuration in php.ini, but they replied that is not php.ini's problem and there is no limitation in curl.

Hossein Shahsahebi
  • 6,348
  • 5
  • 24
  • 38
  • Use realpath function like realpath (ASSET_PATH . '/video/' . $asset->name) in post field – amarjeet kumar Aug 11 '15 at 12:12
  • Can you make sure either ASSET_PATH . '/video/' . $asset->name path is correct? Do one thing, just print get_file_contents(ASSET_PATH . '/video/' . $asset->name); If it prints any contents that means your file path is correct. – amarjeet kumar Aug 11 '15 at 12:18
  • 1
    Looks like an issue on **target** system. Since you appear to have access to it, have you verified upload size limits? – Álvaro González Aug 11 '15 at 19:34
  • 1
    @ÁlvaroG.Vicario thanks dude. you were right. the problem was in my own side and it sends successfully to telegram. Am I have to delete my question or you think it has something useful for others? – Hossein Shahsahebi Aug 11 '15 at 20:29
  • 1
    I guess "no" is also a useful answer :) I've composed an answer. – Álvaro González Aug 12 '15 at 06:34

1 Answers1

16

Upload limits are a security feature. Without them, a rogue program or attacker could feed your server with a continuous stream of data until your hard disk is full, thus rendering the whole server unusable.

From the security standpoint it isn't particularly useful to restrict outgoing data and, as far as I know, neither the Curl library nor PHP itself impose any limit.

Your symptoms suggest the problem is on the destination server. Since you appear to have access to it (you mention getting empty $_POST) I suggest you verify upload limits there. That's something you can do (and often change) yourself, you don't have to ask the server administrator. Main involved directives include:

  • post_max_size
  • upload_max_filesize
  • max_file_uploads
  • max_input_time

You can inspect them with phpinfo() or ini_get() and you can change them the usual way.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
  • Hello Álvaro González, I am also getting the same error. And I have changed the values you have suggested in both my Client and Server side. But it still not working for me. Can you please suggest me some solution? – Ashish Shah Dec 19 '18 at 07:31
  • @AshishShah Have u got any solution for this? – Tejas Khutale Dec 22 '18 at 09:22
  • Hello @TejasKhutale, Yes. I my issues was due to in appropriate Hosting Configuration. In .htaccess I have changed the values for the required params. But in my hosting config, it was not allowed to overwrite. So I changed the conf and added 1 line "Allowoverride All"(in the server side co – Ashish Shah Dec 24 '18 at 06:55