Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP, virtual file from a string without writting on hard disk

Tags:

php

if i have a string ( containing pdf file ) is possible to make a "virtual" file to avoid writting on hard disk, to be later used on a function who requires a existing file?

// theorical code

$file=stringToVirtualFile($string);

require($file);
like image 402
AgelessEssence Avatar asked Jan 15 '23 11:01

AgelessEssence


1 Answers

You can use the special php://memory to have a file handle that reference in-memory data instead of data written to a file. You may also use php://temp to have a file backed memory store (where the file will be written to disk if it exceeds 2MB by default).

like image 118
MatsLindh Avatar answered Jan 28 '23 14:01

MatsLindh