In simple terms this is my process flow and what I need to achieve.
1. Upload an image to assets folder in the app space. This is deployed in
/var/www/html/riuso
This upload script is a file named
upload.php inside the assets folder. This works well.
<?php
header("Access-Control-Allow-Origin: *");
set_time_limit(0);
if (isset($_FILES['upload'])) {
// Example:
if(move_uploaded_file($_FILES['upload']['tmp_name'], "../assets/" . $_FILES['upload']['name'])){
echo '{ "status": "success" }';
} else {
echo '{ "status": "error" }';
}
exit;
} else {
echo '{ "status": "error" }';
}
?>
2. Now in the drive of the server in the folder named
/root/Files, this is outside the app space. I need to create a sub folder and then move the image file there, renaming the image file to be img.png. The code to create folders is in the ruiso.php file above. This is the part I dont know how to achieve.
In the php file above, I have this code to create a folder
function DirectoryMake($dirpath) {
$target_exists = is_dir($dirpath);
if ($target_exists) {
die("yes");
}
mkdir($dirpath, 0700, true);
//return directory existence
$res = DirectoryExists($dirpath);
die($res);
}
function DirectoryExists($path) {
$target_exists = is_dir($path);
if (!$target_exists) {
//source does not exist
die("no");
}
die("yes");
}
I have done a call like
DirectoryMake("/root/Files/Image1"), I am assuming this will assume a process from where the php file resides, it does not work.
Please help.