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


PHP FileUpload::setFolder方法代码示例

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


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

示例1: process

 /**
  * Goes through the array of files and processes them accordingly.
  * The result is an array of the appropiate Resource class that has been
  * created using the ResourceFactory class.
  *
  * @return An array of Upload objects that have already been moved to a safer
  * location.
  */
 function process($destinationFolder)
 {
     // first, check if the upload feature is available
     $config =& Config::getConfig();
     if (!$config->getValue("uploads_enabled")) {
         return FILE_UPLOADS_NOT_ENABLED;
     }
     // array used to store the files that have already been saved
     $uploads = array();
     if ($destinationFolder[strlen($destinationFolder - 1)] != "/") {
         $destinationFolder .= "/";
     }
     foreach ($this->_files as $file) {
         $upload = new FileUpload($file);
         $fileName = $upload->getFileName();
         if ($this->my_move_uploaded_file($upload->getTmpName(), $destinationFolder . $fileName)) {
             $upload->setFolder($destinationFolder);
             $upload->setError(0);
         } else {
             $upload->setError(1);
         }
         array_push($uploads, $upload);
     }
     return $uploads;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:33,代码来源:fileuploads.class.php

示例2: parseMimeParts

 /**
  * checks if there are any mime parts, perhaps attachments or something like
  * that...
  */
 function parseMimeParts($parts)
 {
     $this->_attachments = array();
     foreach ($parts as $part) {
         MoblogLogger::log("attachment type = " . $part->ctype_primary . "/" . $part->ctype_secondary);
         if (strtolower($part->ctype_primary) == "text" && strtolower($part->ctype_secondary) == "plain") {
             // if ctype_primary == text and ctype_secondary == plain, it should be text format e-mail
             MoblogLogger::log("Reparsing the body of the message!");
             MoblogLogger::log("text/plain part - contents = " . $part->body);
             $this->parseBody($part->body);
             $this->_inputEncoding = strtoupper($part->ctype_parameters['charset']);
         } elseif (strtolower($part->ctype_primary) == "multipart" && strtolower($part->ctype_secondary) == "alternative") {
             // if ctype_primary == multipart and ctype_secondary == alternative, it should be html format e-mail
             // We should look into it's child to get the real body
             foreach ($part->parts as $childPart) {
                 if (strtolower($childPart->ctype_primary) == "text" && strtolower($childPart->ctype_secondary) == "plain") {
                     $this->parseBody($childPart->body);
                     $this->_inputEncoding = strtoupper($childPart->ctype_parameters['charset']);
                 }
             }
         } else {
             // whatever comes as a part, we will take it and treat it as if it was
             // a normal resource as long as it's not an application/smil thingie...
             if (strtolower($part->ctype_secondary) != 'html' && strtolower($part->ctype_secondary) != 'smil' && MOBLOG_IGNORE_SMIL_ATTACHMENTS) {
                 // GalleryResources::addResource only deals with uploaded files, so we'll
                 // have to pretend that this is one of them!
                 $config =& Config::getConfig();
                 // $tmpFolder = $config->getValue( "temp_folder" );
                 // $tmpFolderName = $tmpFolder."/".md5(microtime());
                 $tmpFolderName = $config->getValue("temp_folder");
                 File::createDir($tmpFolderName);
                 MoblogLogger::log("Creating temp folder = {$tmpFolderName}");
                 $fileName = stripslashes($part->ctype_parameters["name"]);
                 if ($fileName == "") {
                     $fileName = stripslashes($part->d_parameters["filename"]);
                 }
                 $fileName = str_replace("\"", "", $fileName);
                 $fileName = str_replace("'", "", $fileName);
                 $tmpName = $tmpFolderName . "/" . md5(microtime()) . "_" . $fileName;
                 $fileName = urldecode($fileName);
                 if (MOBLOG_FORCE_ENCODE_TO_UTF8) {
                     $fileName = $this->encodeToUTF8($fileName, $this->_inputEncoding);
                 }
                 $f = new File($tmpName);
                 $f->open("ab+");
                 MoblogLogger::log("fileName = " . $tmpName);
                 MoblogLogger::log("Saving attachment as = " . $tmpName);
                 //MoblogLogger::log( "base64 encoded data = ".$part->body );
                 if (!$f->write($part->body)) {
                     MoblogLogger::log("There was an error writing the temporary file");
                     die;
                 }
                 MoblogLogger::log("File saved ok!");
                 MoblogLogger::log("FILENAME = {$fileName}");
                 $uploadInfo = array("name" => urldecode($fileName), "type" => $part->ctype_primary . "/" . $part->ctype_secondary, "tmp_name" => $tmpName, "size" => $f->getSize(), "error" => 0);
                 $upload = new FileUpload($uploadInfo);
                 $upload->setFolder($tmpFolderName);
                 array_push($this->_attachments, $upload);
             }
         }
     }
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:66,代码来源:moblogrequest.class.php


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