本文整理汇总了PHP中CFile::moveFile方法的典型用法代码示例。如果您正苦于以下问题:PHP CFile::moveFile方法的具体用法?PHP CFile::moveFile怎么用?PHP CFile::moveFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::moveFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doStore
/**
* @see parent::doStore()
*/
function doStore()
{
if (isset($_FILES['attachment'])) {
$mail_id = CValue::post('mail_id');
$mail = new CUserMail();
$mail->load($mail_id);
$files = array();
foreach ($_FILES['attachment']['error'] as $key => $file_error) {
if (isset($_FILES['attachment']['name'][$key])) {
$files[] = array('name' => $_FILES['attachment']['name'][$key], 'tmp_name' => $_FILES['attachment']['tmp_name'][$key], 'error' => $_FILES['attachment']['error'][$key], 'size' => $_FILES['attachment']['size'][$key]);
}
}
foreach ($files as $_key => $_file) {
if ($_file['error'] == UPLOAD_ERR_NO_FILE) {
continue;
}
if ($_file['error'] != 0) {
CAppUI::setMsg(CAppUI::tr("CFile-msg-upload-error-" . $_file["error"]), UI_MSG_ERROR);
continue;
}
$attachment = new CMailAttachments();
$attachment->name = $_file['name'];
$content_type = mime_content_type($_file['tmp_name']);
$attachment->type = $attachment->getTypeInt($content_type);
$attachment->bytes = $_file['size'];
$attachment->mail_id = $mail_id;
$content_type = explode('/', $content_type);
$attachment->subtype = strtoupper($content_type[1]);
$attachment->disposition = 'ATTACHMENT';
$attachment->extension = substr(strrchr($attachment->name, '.'), 1);
$attachment->part = $mail->countBackRefs('mail_attachments') + 1;
$attachment->store();
$file = new CFile();
$file->setObject($attachment);
$file->author_id = CAppUI::$user->_id;
$file->file_name = $attachment->name;
$file->file_date = CMbDT::dateTime();
$file->fillFields();
$file->updateFormFields();
$file->doc_size = $attachment->bytes;
$file->file_type = mime_content_type($_file['tmp_name']);
$file->moveFile($_file, true);
if ($msg = $file->store()) {
CAppUI::setMsg(CAppUI::tr('CMailAttachments-error-upload-file') . ':' . CAppUI::tr($msg), UI_MSG_ERROR);
CApp::rip();
}
$attachment->file_id = $file->_id;
if ($msg = $attachment->store()) {
CAppUI::setMsg($msg, UI_MSG_ERROR);
CApp::rip();
}
}
CAppUI::setMsg('CMailAttachments-msg-added', UI_MSG_OK);
} else {
parent::doStore();
}
}
示例2: addFile
/**
* Create a CFile attachment to given CMbObject
* @return string store-like message, null if successful
*/
function addFile(CMbObject $object)
{
$user = CUser::get();
$this->saveFile();
$file = new CFile();
$file->object_id = $object->_id;
$file->object_class = $object->_class;
$file->file_name = "{$object->_guid}.xml";
$file->file_type = "text/xml";
$file->doc_size = filesize($this->documentfilename);
$file->file_date = CMbDT::dateTime();
$file->file_real_filename = uniqid(rand());
$file->author_id = $user->_id;
$file->private = 0;
if (!$file->moveFile($this->documentfilename)) {
return "error-CFile-move-file";
}
return $file->store();
}
示例3: uniqid
// store file with a unique name
$obj->file_name = $upload['name'];
$obj->file_type = $upload['type'];
$obj->file_size = $upload['size'];
$obj->file_date = str_replace("'", '', $db->DBTimeStamp(time()));
$obj->file_real_filename = uniqid(rand());
$res = $obj->moveTemp($upload);
if (!$res) {
$AppUI->setMsg('File could not be written', UI_MSG_ERROR);
$AppUI->redirect();
}
}
}
// move the file on filesystem if the affiliated project was changed
if ($file_id && $obj->file_project != $oldObj->file_project) {
$res = $obj->moveFile($oldObj->file_project, $oldObj->file_real_filename);
if (!$res) {
$AppUI->setMsg('File could not be moved', UI_MSG_ERROR);
$AppUI->redirect();
}
}
if (!$file_id) {
$obj->file_owner = $AppUI->user_id;
if (!$obj->file_version_id) {
$q = new DBQuery();
$q->addTable('files');
$q->addQuery('file_version_id');
$q->addOrder('file_version_id DESC');
$q->setLimit(1);
$sql = $q->prepare();
$q->clear();
示例4: dPgetParam
$redirect = dPgetParam($_POST, 'redirect', '');
$bulk_file_project = dPgetParam($_POST, 'bulk_file_project', 'O');
$bulk_file_folder = dPgetParam($_POST, 'bulk_file_folder', 'O');
if (is_array($selected) && count($selected)) {
$upd_file = new CFile();
foreach ($selected as $key => $val) {
if ($key) {
$upd_file->load($key);
}
if (isset($_POST['bulk_file_project']) && $bulk_file_project != '' && $bulk_file_project != 'O') {
if ($upd_file->file_id) {
// move the file on filesystem if the affiliated project was changed
if ($upd_file->file_project != $bulk_file_project) {
$oldProject = $upd_file->file_project;
$upd_file->file_project = $bulk_file_project;
$res = $upd_file->moveFile($oldProject, $upd_file->file_real_filename);
if (!$res) {
$AppUI->setMsg('At least one File could not be moved', UI_MSG_ERROR);
}
}
$upd_file->store();
}
}
if (isset($_POST['bulk_file_folder']) && $bulk_file_folder != '' && $bulk_file_folder != 'O') {
if ($upd_file->file_id) {
$upd_file->file_folder = $bulk_file_folder;
$upd_file->store();
}
}
echo db_error();
}
示例5: CSupervisionTimedPicture
/**
* $Id: do_select_supervision_picture.php 26555 2014-12-23 12:48:14Z flaviencrochard $
*
* @category Patients
* @package Mediboard
* @author SARL OpenXtrem <dev@openxtrem.com>
* @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html
* @version $Revision: 26555 $
* @link http://www.mediboard.org
*/
CCanDo::checkAdmin();
$path = str_replace("..", "", CValue::post("path"));
$timed_picture_id = CValue::post("timed_picture_id");
if (is_file($path) && strpos(CSupervisionTimedPicture::PICTURES_ROOT, $path) !== 0) {
$timed_picture = new CSupervisionTimedPicture();
$timed_picture->load($timed_picture_id);
$file = new CFile();
$file->setObject($timed_picture);
$file->fillFields();
$file->file_name = basename($path);
$file->doc_size = filesize($path);
$file->file_type = CMbPath::guessMimeType($path);
$file->moveFile($path, false, true);
if ($msg = $file->store()) {
CAppUI::setMsg($msg, UI_MSG_WARNING);
} else {
CAppUI::setMsg("Image enregistrée");
}
}
echo CAppUI::getMsg();
CApp::rip();
示例6: CFile
// If there was a file that was attached to both the task, and the task
// has moved projects, we need to move the file as well
if ($move_files) {
require_once $AppUI->getModuleClass('files');
$filehandler = new CFile();
$q = new DBQuery();
$q->addTable('files', 'f');
$q->addQuery('file_id');
$q->addWhere('file_task = ' . (int) $obj->task_id);
$files = $q->loadColumn();
if (!empty($files)) {
foreach ($files as $file) {
$filehandler->load($file);
$realname = $filehandler->file_real_filename;
$filehandler->file_project = $obj->task_project;
$filehandler->moveFile($move_files, $realname);
$filehandler->store();
}
}
}
$AppUI->setMsg($task_id ? 'Task updated' : 'Task added', UI_MSG_OK);
}
if (isset($hassign)) {
$obj->updateAssigned($hassign, $hperc_assign_ar);
}
if (isset($hdependencies)) {
// && !empty($hdependencies)) {
// there are dependencies set!
// backup initial start and end dates
$tsd = new CDate($obj->task_start_date);
$ted = new CDate($obj->task_end_date);