@@ -363,6 +363,7 @@ private static function setUpRequestParams(array $data)
363363 // Magical media input helper.
364364 $ item = self ::mediaInputHelper ($ item , $ has_resource , $ multipart );
365365 } elseif (array_key_exists (self ::$ current_action , self ::$ input_file_fields ) && in_array ($ key , self ::$ input_file_fields [self ::$ current_action ], true )) {
366+ // Allow absolute paths to local files.
366367 if (is_string ($ item ) && file_exists ($ item )) {
367368 $ item = new Stream (self ::encodeFile ($ item ));
368369 }
@@ -397,9 +398,17 @@ private static function setUpRequestParams(array $data)
397398 * and
398399 * Request::sendMediaGroup([
399400 * 'media' => [
400- * new InputMediaPhoto(['media' => Request::encodeFile($photo_1)]),
401- * new InputMediaPhoto(['media' => Request::encodeFile($photo_2)]),
402- * new InputMediaVideo(['media' => Request::encodeFile($video_1)]),
401+ * new InputMediaPhoto(['media' => Request::encodeFile($local_photo_1)]),
402+ * new InputMediaPhoto(['media' => Request::encodeFile($local_photo_2)]),
403+ * new InputMediaVideo(['media' => Request::encodeFile($local_video_1)]),
404+ * ],
405+ * ]);
406+ * and even
407+ * Request::sendMediaGroup([
408+ * 'media' => [
409+ * new InputMediaPhoto(['media' => $local_photo_1]),
410+ * new InputMediaPhoto(['media' => $local_photo_2]),
411+ * new InputMediaVideo(['media' => $local_video_1]),
403412 * ],
404413 * ]);
405414 *
@@ -420,6 +429,12 @@ private static function mediaInputHelper($item, &$has_resource, array &$multipar
420429 }
421430
422431 $ media = $ media_item ->getMedia ();
432+
433+ // Allow absolute paths to local files.
434+ if (is_string ($ media ) && file_exists ($ media )) {
435+ $ media = new Stream (self ::encodeFile ($ media ));
436+ }
437+
423438 if (is_resource ($ media ) || $ media instanceof Stream) {
424439 $ has_resource = true ;
425440 $ rnd_key = uniqid ('media_ ' , false );
0 commit comments