I need to get the content of some files in order to upload them in a second moment.
The files are placed in one of the project folders (project_name_root/docs/).
I retrieve the file content dynamically and the problem is that that content is always the same. What is read is always the first file content and not all the other ones, even tough the filename getting saved is actually correct.
Basically I have and index.php where I create the instance, then I get the file names and then I call the insert_doc function for each of them. So, what could be the problem? Thanks!
index.php
require_once('DOCAREAProto.class.php');
$instance = new DOCAREAProto("AGSPRWS","AGSPRWS");
$files = "SELECT...";
foreach($files as $file) {
$DOCUMENTS = [
"P" => [
"name" => $file['name'].".pdf",
"path" => "docs/",
]
];
$instance->insert_doc($DOCUMENTS);
}
DOCAREAProto.class.php
class DOCAREAProto{
private $DOCUMENTS = [];
function insert_doc($documents){
$this->DOCUMENTS = $documents;
$name = $this->DOCUMENTS["P"]['name'];
$path = $this->DOCUMENTS['P']['path'];
$file = $path.$name;
$doc = file_get_contents($file);
...
}