I have some code that is supposed to upload a file and move it to the correct folder:
$check = getimagesize($files['image']['tmp_name']);
if($check !== false)
{
$dir = "/var/www/public_html/images/";
$file = $dir.basename($files['image']['name']);
if(file_exists($file))
{
$img = "https://example.com/images/".basename($files['image']['name']);
}
else
{
move_uploaded_file($files['image']['tmp_name'], $file);
$img = "https://example.com/images/".basename($files['image']['name']);
}
}
The issue is that this code is in a function (and a different file), so I cannot directly use $_FILES
. In my other file, where the post occurs, I have this:
Images::editImage($post, $_FILES)
It works for post, but not for files. Is there any way to carry $_FILES
across files?