Create an new file instance

In phalcon you can get uploaded file with this piece of code

    //Check if the user has uploaded files
    if ($this->request->hasFiles() == true) {
        //Print the real file names and their sizes
        foreach ($this->request->getUploadedFiles() as $file){
            echo $file->getName(), " ", $file->getSize(), "\n";
        }
    }

each $file is an Phalcon\Http\Request\File instance.

But what if I want to create an file instance from an existing file on the server, how can I do that?

What I tried is this:

    new Phalcon\Http\Request\File(array($fileDir));

But it returns an instance with empty properties.

any help would be appreciated :D



48.4k

It sounds like you need to be using the standard PHP file functions and that it has nothing to do with an upload.



725

It would be verry usefull to reuse the File class!

But if it is not possible, I can write one myself so al the file data is stored in one object. Which would help me to prevent googling how to read,write,move or copy a file and its properties in plain php