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


PHP PerchUtil::move_uploaded_file方法代码示例

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


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

示例1: write_file

 public function write_file($file, $name)
 {
     $filename = PerchUtil::tidy_file_name($name);
     if (strpos($filename, '.php') !== false) {
         $filename .= '.txt';
     }
     // diffuse PHP files
     if (strpos($filename, '.phtml') !== false) {
         $filename .= '.txt';
     }
     // diffuse PHP files
     $target = PerchUtil::file_path($this->file_path . '/' . $filename);
     if (file_exists($target)) {
         $dot = strrpos($filename, '.');
         $filename_a = substr($filename, 0, $dot);
         $filename_b = substr($filename, $dot);
         $count = 1;
         while (file_exists(PerchUtil::file_path($this->file_path . '/' . PerchUtil::tidy_file_name($filename_a . '-' . $count . $filename_b)))) {
             $count++;
         }
         $filename = PerchUtil::tidy_file_name($filename_a . '-' . $count . $filename_b);
         $target = PerchUtil::file_path($this->file_path . '/' . $filename);
     }
     PerchUtil::move_uploaded_file($file, $target);
     return array('name' => $filename, 'path' => $target);
 }
开发者ID:Bloom-web,项目名称:bloom-web,代码行数:26,代码来源:PerchResourceBucket.class.php

示例2: strrpos

             }
             //checking for naughty uploading of php files.
             $target = PERCH_RESFILEPATH . DIRECTORY_SEPARATOR . $filename;
             if (file_exists($target)) {
                 $ext = strrpos($filename, '.');
                 $fileName_a = substr($filename, 0, $ext);
                 $fileName_b = substr($filename, $ext);
                 $count = 1;
                 while (file_exists(PERCH_RESFILEPATH . DIRECTORY_SEPARATOR . $fileName_a . '_' . $count . $fileName_b)) {
                     $count++;
                 }
                 $filename = $fileName_a . '_' . $count . $fileName_b;
                 $target = PERCH_RESFILEPATH . DIRECTORY_SEPARATOR . $filename;
             }
         }
         PerchUtil::move_uploaded_file($_FILES['upload']['tmp_name'], $target);
         if (is_object($Image)) {
             $Image->process_versions($filename, $Template);
         }
     }
     if ($new_image) {
         PerchUtil::redirect($API->app_path() . '/images/edit/?album_id=' . $albumID . '&id=' . $result->id() . '&created=1');
     } else {
         $message = $HTML->success_message('Your image has been successfully updated. Return to %simage listing%s', '<a href="' . $API->app_path() . '/images/?id=' . $albumID . '">', '</a>');
     }
 } else {
     $message = $HTML->failure_message('Sorry, that image could not be updated.');
 }
 if (is_object($Image)) {
     $details = $Image->to_array();
 } else {
开发者ID:pete-naish,项目名称:4hair,代码行数:31,代码来源:image.edit.pre.php

示例3: foreach

    }
    if (isset($_POST['logo_remove']) && $_POST['logo_remove'] == '1') {
        $data['logoPath'] = '';
    }
    foreach ($data as $key => $value) {
        $Settings->set($key, $value);
    }
    $Lang = PerchLang::fetch();
    $Lang->reload();
    $Alert->set('success', PerchLang::get("Your settings have been updated."));
    // image upload
    if (isset($_FILES['customlogo']) && (int) $_FILES['customlogo']['size'] > 0) {
        if (is_array(getimagesize($_FILES['customlogo']['tmp_name']))) {
            $filename = $_FILES['customlogo']['name'];
            if (strpos($filename, '.php') !== false) {
                $filename .= '.txt';
            }
            // diffuse PHP files
            $target = PERCH_RESFILEPATH . '/' . $filename;
            if (file_exists($target)) {
                $filename = time() . '_' . $_FILES['customlogo']['name'];
                $target = PERCH_RESFILEPATH . '/' . $filename;
            }
            PerchUtil::move_uploaded_file($_FILES['customlogo']['tmp_name'], $target);
            $Settings->set('logoPath', PERCH_RESPATH . '/' . $filename);
        }
    }
    $Settings->reload();
}
PerchUtil::debug('Image folder writable? ' . $image_folder_writable);
$details = $Settings->get_as_array();
开发者ID:TodayIShould,项目名称:todayishould_website,代码行数:31,代码来源:basic.pre.php

示例4: process_response

 public function process_response($SubmittedForm)
 {
     $opts = $this->_load_options();
     $data = array();
     $data['fields'] = array();
     $data['files'] = array();
     $data['page'] = $SubmittedForm->page;
     if (class_exists('PerchContent_Pages')) {
         $Pages = new PerchContent_Pages();
         $Page = $Pages->find_by_path($SubmittedForm->page);
         if ($Page) {
             $data['page'] = array('id' => $Page->pageID(), 'title' => $Page->pageTitle(), 'path' => $Page->pagePath(), 'navtext' => $Page->pageNavText());
         }
     }
     // Anti-spam
     $spam = false;
     $antispam = $SubmittedForm->get_antispam_values();
     $environment = $_SERVER;
     $akismetAPIKey = false;
     if (isset($opts->akismet) && $opts->akismet) {
         if (isset($opts->akismetAPIKey) && $opts->akismetAPIKey != '') {
             $akismetAPIKey = $opts->akismetAPIKey;
         }
     }
     $spam = $this->_check_for_spam($antispam, $environment, $akismetAPIKey);
     // Files
     if (!$spam && PerchUtil::count($SubmittedForm->files)) {
         if (isset($opts->fileLocation) && $opts->fileLocation != '') {
             foreach ($SubmittedForm->files as $key => &$details) {
                 if ($details['error'] == '0' && $details['size'] > 0) {
                     // no error, upload worked
                     $attrs = $SubmittedForm->get_template_attributes($key);
                     if (is_uploaded_file($details['tmp_name'])) {
                         $filename = $details['name'];
                         $dest = rtrim($opts->fileLocation, '\\/') . DIRECTORY_SEPARATOR;
                         if (file_exists($dest . $filename)) {
                             $filename = time() . $filename;
                         }
                         if (file_exists($dest . $filename)) {
                             $filename = time() . mt_rand() . $filename;
                         }
                         if (PerchUtil::move_uploaded_file($details['tmp_name'], $dest . $filename)) {
                             $details['new_path'] = $dest . $filename;
                             $details['new_filename'] = $filename;
                             $file = new stdClass();
                             $file->name = $filename;
                             $file->path = $dest . $filename;
                             $file->size = $details['size'];
                             $file->mime = '';
                             if (isset($SubmittedForm->mimetypes[$key])) {
                                 $file->mime = $SubmittedForm->mimetypes[$key];
                             }
                             $file->attributes = $attrs->get_attributes();
                             $data['files'][$key] = $file;
                         }
                     }
                 }
             }
         } else {
             PerchUtil::debug('Form ' . $SubmittedForm->id . ': File save location not set, files discarded.', 'error');
         }
     }
     // Fields
     if (PerchUtil::count($SubmittedForm->data)) {
         foreach ($SubmittedForm->data as $key => $value) {
             $attrs = $SubmittedForm->get_template_attributes($key);
             if ($attrs) {
                 $field = new stdClass();
                 $field->attributes = $attrs->get_attributes();
                 // skip submit fields
                 if (isset($field->attributes['type']) && $field->attributes['type'] == 'submit') {
                     // skip it.
                 } else {
                     // skip honeypot field
                     if (isset($field->attributes['antispam']) && $field->attributes['antispam'] == 'honeypot') {
                         // skip it
                     } else {
                         $field->value = $value;
                         $data['fields'][$attrs->id()] = $field;
                     }
                 }
             }
         }
     }
     if (!$spam && isset($opts->email) && $opts->email) {
         $this->_send_email($opts, $data);
     }
     if (isset($opts->store) && $opts->store) {
         $json = PerchUtil::json_safe_encode($data);
         $record = array();
         $record['responseJSON'] = $json;
         $record['formID'] = $this->id();
         $record['responseIP'] = $_SERVER['REMOTE_ADDR'];
         if ($spam) {
             $record['responseSpam'] = '1';
         }
         $spam_data = array();
         $spam_data['fields'] = $antispam;
         $spam_data['environment'] = $environment;
         $record['responseSpamData'] = PerchUtil::json_safe_encode($spam_data);
//.........这里部分代码省略.........
开发者ID:scottbrabazon,项目名称:scottbrabazon.com,代码行数:101,代码来源:PerchForms_Form.class.php


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