I
I
inavo2020-04-16 17:20:34
symfony
inavo, 2020-04-16 17:20:34

How do I pre-estimate the size of a file?

How can you pre-estimate the size of a generated file using dumpFile of the Symfony\Component\Filesystem class ?
In the class itself, I did not notice such an option.
Or do you still have to create a temporary file and see how long it took?

The code:

use Symfony\Component\Filesystem\Filesystem;

$filesystem = new Filesystem();

$filesystem->touch($_SERVER['DOCUMENT_ROOT'] . $url);

$filesystem->dumpFile($_SERVER['DOCUMENT_ROOT'] . $url, $data);    // 5797960 bytes

strlen($data);        // 5236968 bytes

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question