When using move_uploaded_file()
I am trying to dynamically find the path to a img folder so that I can have the command working on both my local development server (XAMPP) and my remote production server. This is currently the function that I am using.
public function storePicture(): bool
{
$this->setNewPath('C:\fakepath\_img\uploads\\' . $this->getName());
if (move_uploaded_file($this->getTmpName(), $this->getNewPath())) {
return true;
} else {
return false;
}
}
Please note the \ is just to escape out that slash and really isn't important to look at because IT WORKS on my development server. I have tired using dirname() and it seems to be ALMOST working, except that it has reversed slashes and only gets the path from the root of the server directory. That probably will work on my production server but not on my development server apparently.