Alternate to $_FILES in OXID

I was refractoring the code for my module certification and i came across to the part of documentation where it says:

Do not use global variables like:

$_POST
$_GET
$_SERVER
// etc.

And this is my code which i want to refactor:

       if ($_FILES) {
            $filename = $_FILES["orderpdf"]["name"];
            $tmpfname = $_FILES["orderpdf"]["tmp_name"];
            $pdfData = $this->uploadAndReturnEncodedContent($filename, $tmpfname);
        }

I know i can use:

$oConfig = Registry::getConfig()->getUploadedFile("orderpdf")

to get files content such as name, But what is the alternate of the IF statement block?

       if (what_is_the_alternate_of_$_FILES) {
           
        }

Using OXID version CE 6.1.4

take a look at
https://www.php.net/manual/en/reserved.variables.files.php
or
https://www.php.net/manual/en/features.file-upload.php

maybe if ($oConfig->getUploadedFile("myfile"))

1 Like

I know how to use $_FILES i asked if there any alternate to it, Because in documentation its mentioned dont use global variables like: $_SESSION $_POST $_GET etc

Yeah i think this will do, Thanks! will try this.