-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Description
Description
$a = fopen('php://input', 'r');
var_dump(stream_get_meta_data($a)['seekable']);
var_dump(ftell($a));
var_dump(fseek($a, 10, SEEK_SET));
var_dump(ftell($a));
Resulted in this output:
bool(true)
int(0)
int(-1)
bool(false)
But I expected this output instead:
bool(true)
int(0)
int(0)
int(10)
If you actually read through to the end of the stream, it becomes seekable:
$a = fopen('php://input', 'r');
while (!feof($a)) {
fread($a, 8192);
}
var_dump(stream_get_meta_data($a)['seekable']);
var_dump(ftell($a));
var_dump(fseek($a, 10, SEEK_SET));
var_dump(ftell($a));
var_dump(fseek($a, 0, SEEK_END));
var_dump(ftell($a));
Results in what is expected:
bool(true)
int(30320)
int(0)
int(10)
int(0)
int(30320)
PHP Version
PHP/8.1.9
Operating System
Debian stable