$object->setPassport(implode("\n", $rtn)); // proceed for $graduation_certificate $files = explode("\n", trim($graduation_certificate)); $rtn = array(); foreach ($files as $file) { $file = trim($file); // for cache file, we move it to its proper location if (strpos($file, str_replace(WEBROOT . DS, "", CACHE_DIR)) === 0) { $oldname = WEBROOT . DS . $file; $newname = WEBROOT . DS . "files/application" . str_replace(CACHE_DIR, "", WEBROOT . DS . $file); rename($oldname, $newname); $file = str_replace(WEBROOT . DS, "", $newname); } $rtn[] = $file; } $object->setGraduationCertificate(implode("\n", $rtn)); // proceed for $degree_certificate $files = explode("\n", trim($degree_certificate)); $rtn = array(); foreach ($files as $file) { $file = trim($file); // for cache file, we move it to its proper location if (strpos($file, str_replace(WEBROOT . DS, "", CACHE_DIR)) === 0) { $oldname = WEBROOT . DS . $file; $newname = WEBROOT . DS . "files/application" . str_replace(CACHE_DIR, "", WEBROOT . DS . $file); rename($oldname, $newname); $file = str_replace(WEBROOT . DS, "", $newname); } $rtn[] = $file; } $object->setDegreeCertificate(implode("\n", $rtn));