[php-src] Issue #19249: http context - allow content to be a stream/resource

From: Date: Sat, 26 Jul 2025 15:17:04 +0000
Subject: [php-src] Issue #19249: http context - allow content to be a stream/resource
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-250500@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/19249 Author: rbro ### Description I am using file_get_contents with a HTTP context to POST a large request to a URL (https://www.php.net/manual/en/context.http.php). I noticed that the content field has to be a string: ``` <?php $post_data = file_get_contents('data_to_send.txt'); file_get_contents('https://test.com/test.php', false, stream_context_create(array( 'http' => array( 'method' => 'POST', 'header' => array( 'Content-type: multipart/form-data', ), 'content' => $post_data, ) ))); ?> ``` Would it be possible to allow content to be a stream/resource so that I don't have to read in the file contents first? This would be similar to CURLOPT_INFILE which accepts a file handle resource like fopen. The reason I'm trying to send data this way and not with curl is because of #15859. I'm trying to build my own multipart/form-data request per [my comment](https://github.com/php/php-src/issues/15859#issuecomment-3115393329) there, as I'm connecting to an API that needs multiple files with the same name. Thanks for your help.

« previous php.bugs (#250500) next »