This is the start code of my upload function,
function upload()
{
$str_path = "../users/$this->user_name/$this->profile_image";
if (!is_dir("../users")) {
if (!mkdir("../users")) {
throw new Exception("failed to create folder ../users");
}
}
if (!is_dir("../users/$this->user_name")) {
if (!mkdir("../users/$this->user_name")) {
throw new Exception("failed to create folder ../users/$this->user_name");
}
}
}
There is a main folder in which all web pages are saved, that is “project” folder. I have a models folder, the class containing the upload function is in there. Then I have a process folder from where the upload function is called and it creates folders in the main “project” folder and uploads the file.
The problem is that I am also using the same function from “projects/users/process” folder. The upload path is set in upload function but the function is called from two different locations hence it creates a folder in “projects/users” folder when called from “projects/users/process”, though I need it to be creating folders and uploading always in “projects