/** * Move uploaded file to the user folder from the tmp folder * @param $userID * @param $file * @param $targetWidth * @param $targetHeight * @param null $sourceX * @param null $sourceY * @param null $sourceWidth * @param null $sourceHeight */ public static function moveFileFromTmpToUserFolder($userID, $file, $targetWidth, $targetHeight, $sourceX = null, $sourceY = null, $sourceWidth = null, $sourceHeight = null) { $dir = DIR_FS_PHOTO . "users"; if (!is_dir($dir)) { mkdir($dir, 0777); $fp = fopen($dir . "/index.html", "w"); fclose($fp); } $dir = $dir . "/" . $userID; if (!is_dir($dir)) { mkdir($dir, 0777); $fp = fopen($dir . "/index.html", "w"); fclose($fp); } $dir_org = $dir . "/original"; if (!is_dir($dir_org)) { mkdir($dir_org, 0777); $fp = fopen($dir_org . "/index.html", "w"); fclose($fp); } $dir_resized = $dir . "/resized"; if (!is_dir($dir_resized)) { mkdir($dir_resized, 0777); $fp = fopen($dir_resized . "/index.html", "w"); fclose($fp); } $dir_thumbnail = $dir . "/thumbnail"; if (!is_dir($dir_thumbnail)) { mkdir($dir_thumbnail, 0777); $fp = fopen($dir_thumbnail . "/index.html", "w"); fclose($fp); } // Move File to the original folder $fp1 = fopen(DIR_FS_PHOTO_TMP . $file, "r"); $fp2 = fopen($dir_org . "/" . $file, "w"); $buff = fread($fp1, filesize(DIR_FS_PHOTO_TMP . $file)); fwrite($fp2, $buff); fclose($fp1); fclose($fp2); // Remove Tmp File @unlink(DIR_FS_PHOTO_TMP . $file); // Resize The Image BuckysPost::resizeImage($userID, $file, $targetWidth, $targetHeight, $sourceX, $sourceY, $sourceWidth, $sourceHeight); }