当前位置: 首页>>代码示例>>PHP>>正文


PHP CFile::moveTemp方法代码示例

本文整理汇总了PHP中CFile::moveTemp方法的典型用法代码示例。如果您正苦于以下问题:PHP CFile::moveTemp方法的具体用法?PHP CFile::moveTemp怎么用?PHP CFile::moveTemp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFile的用法示例。


在下文中一共展示了CFile::moveTemp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: store

 function store($object_id)
 {
     global $AppUI, $db, $_FILES, $m, $_POST;
     $file_uploaded = false;
     // instantiate the file object and eventually load exsiting file data
     $obj = new CFile();
     if ($_POST[$this->field_name . '_id']) {
         $obj->load($_POST[$this->field_name . '_id']);
         // create an old object for the case that
         // the file must be replaced
         if ($_POST[$this->field_name . '_id'] > 0) {
             $oldObj = new CFile();
             $oldObj->load($_POST[$this->field_name . '_id']);
         }
     }
     // if the cf lives in the projects module
     // affiliate the file to the suitable project
     if ($m == 'projects' && !empty($_POST['project_id'])) {
         $obj->file_project = $_POST['project_id'];
     }
     // todo: implement task affiliation here, too
     $upload = null;
     if (isset($_FILES[$this->field_name])) {
         $upload = $_FILES[$this->field_name];
         if ($upload['size'] > 0) {
             // 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());
             $obj->file_owner = $AppUI->user_id;
             $obj->file_version++;
             $obj->file_version_id = $obj->file_id;
             $res = $obj->moveTemp($upload);
             if ($res) {
                 $file_uploaded = true;
             }
             if ($msg = $obj->store()) {
                 $AppUI->setMsg($msg, UI_MSG_ERROR);
             } else {
                 // reset the cf field_name to the file_id
                 $this->setValue($obj->file_id);
             }
         }
     }
     // Delete the existing (old) file in case of file replacement
     // (through addedit not through c/o-versions)
     if ($_POST[$this->field_name . '_id'] && $upload['size'] > 0 && $file_uploaded) {
         $oldObj->deleteFile();
     }
     if ($upload['size'] > 0 && $file_uploaded) {
         return parent::store($object_id);
     } else {
         if ($upload['size'] > 1 && !$file_uploaded) {
             $AppUI->setMsg('File could not be stored!', UI_MSG_ERROR, true);
             return true;
         }
     }
 }
开发者ID:illuminate3,项目名称:dotproject,代码行数:60,代码来源:CustomFields.class.php

示例2: uniqid

$upload = null;
if (isset($_FILES['formfile'])) {
    $upload = $_FILES['formfile'];
    if ($upload['size'] < 1) {
        if (!$file_id) {
            $AppUI->setMsg('Upload file size is zero. Process aborted.', UI_MSG_ERROR);
            $AppUI->redirect();
        }
    } else {
        // 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) {
开发者ID:Esleelkartea,项目名称:gestion-de-primeras-muestras,代码行数:31,代码来源:do_file_aed.php

示例3: doStore


//.........这里部分代码省略.........
             /** @var CFile $obj */
             $obj = $this->_obj;
             $file_name = "";
             $nb_converted = 0;
             foreach ($aFiles as $key => $file) {
                 $converted = 0;
                 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;
                 }
                 // Si c'est un pdf, on le rajoute sans aucun traitement
                 if (substr(strrchr($file["name"], '.'), 1) == "pdf") {
                     $file_name .= substr($file["name"], 0, strpos($file["name"], '.'));
                     $pdf->addPDF($file["tmp_name"], 'all');
                     $nb_converted++;
                     $converted = 1;
                 } else {
                     if ($obj->isPDFconvertible($file["name"]) && $obj->convertToPDF($file["tmp_name"], $file["tmp_name"] . "_converted")) {
                         $pdf->addPDF($file["tmp_name"] . "_converted", 'all');
                         $file_name .= substr($file["name"], 0, strpos($file["name"], '.'));
                         $nb_converted++;
                         $converted = 1;
                     } else {
                         $other_file = new CFile();
                         $other_file->bind($file);
                         $other_file->file_name = $file["name"];
                         $other_file->file_type = $file["type"];
                         $other_file->doc_size = $file["size"];
                         $other_file->fillFields();
                         $other_file->private = CValue::post("private");
                         if (false == ($res = $other_file->moveTemp($file))) {
                             CAppUI::setMsg("Fichier non envoyé", UI_MSG_ERROR);
                             continue;
                         }
                         $other_file->author_id = CAppUI::$user->_id;
                         if ($msg = $other_file->store()) {
                             CAppUI::setMsg("Fichier non enregistré: {$msg}", UI_MSG_ERROR);
                             continue;
                         }
                         CAppUI::setMsg("Fichier enregistré", UI_MSG_OK);
                     }
                 }
                 // Pour le nom du pdf de fusion, on concatène les noms des fichiers
                 if ($key != count($aFiles) - 1 && $converted) {
                     $file_name .= "-";
                 }
             }
             // Si des fichiers ont été convertis et ajoutés à PDFMerger,
             // création du cfile.
             if ($nb_converted) {
                 $obj->file_name = $file_name . ".pdf";
                 $obj->file_type = "application/pdf";
                 $obj->author_id = CAppUI::$user->_id;
                 $obj->private = CValue::post("private");
                 $obj->object_id = CValue::post("object_id");
                 $obj->object_class = CValue::post("object_class");
                 $obj->updateFormFields();
                 $obj->fillFields();
                 $obj->forceDir();
                 $tmpname = tempnam("/tmp", "pdf_");
                 $pdf->merge('file', $tmpname);
                 $obj->doc_size = strlen(file_get_contents($tmpname));
                 $obj->moveFile($tmpname);
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:67,代码来源:CFileAddEdit.class.php

示例4: CFile

<?php

/**
 * $Id$
 *
 * @category Files
 * @package  Mediboard
 * @author   SARL OpenXtrem <dev@openxtrem.com>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  $Revision$
 * @link     http://www.mediboard.org
 */
$path = CValue::post("path");
$object_class = CValue::post("object_class");
$object_id = CValue::post("object_id");
$file = new CFile();
$file->object_class = $object_class;
$file->object_id = $object_id;
$file->author_id = CAppUI::$user->_id;
$file->file_name = basename($path);
$file->fillFields();
$file->forcerDir();
if ($msg = $file->store()) {
    CAppUI::setMsg($msg, UI_MSG_ERROR);
    return;
}
$file->moveTemp($path);
开发者ID:fbone,项目名称:mediboard4,代码行数:27,代码来源:ajax_fast_add_file.php


注:本文中的CFile::moveTemp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。