'I want to upload an image from a web page but targeted directories are two of two different websites with different url

I have a website on my server and website have two urls and both urls have directories. Actually one url is for app and second for website. Now, I want to upload an image from by website and I want to upload that image in both app and website directory. There is using a mkdir function to upload in single website directory. Now I want to change my function for both urls.

$folder = $folder_url . '/' . $user_id;
if (!file_exists($folder)) {
    mkdir($folder, 0777, true);
}
if (is_null($extension)) {
    $filePath = $folder . "/" . $fileName . '.png';
} else {
    $filePath = $folder . "/" . $fileName . '.'.$extension;
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source