We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon\Http\Request\File get raw content

I need to get the raw content of a Phalcon\Http\Request\File but it seems to be imposible from the api. Would be great if this could be done in a simple way. For now I will use the temp name to access the file.

using $_FILES[] ??



3.4k
edited Mar '17

What's wrong with file_get_contents($file->getTempName());? Also, ensure you validate the MIME type of the file before you do anything with it.

This class provides OO wrappers to the $_FILES superglobal.

Raw method does not exist.

The idea is to have a safe way to store files, not to access them directly.

PHP saves files into /tmp location, thus, you can only access it there once you get the name.

edited Mar '17

yep, I used the usual approach, just wondering if Pahlcon does not deserve a real File abstraction, wich by the way could be used by the Http/Request File

this worked for me

What's wrong with file_get_contents($file->getTempName());? Also, ensure you validate the MIME type of the file before you do anything with it.