• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP file_copy函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中file_copy函数的典型用法代码示例。如果您正苦于以下问题:PHP file_copy函数的具体用法?PHP file_copy怎么用?PHP file_copy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: run

 public function run($args)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'ifcheck=:ifcheck';
     $criteria->params = array(':ifcheck' => '已通过');
     $news = Bl::model()->findAll($criteria);
     foreach ($news as $new) {
         $node = new stdClass();
         $node->title = $new->title;
         $node->field_phone['und'][0]['value'] = $new->phone;
         $node->type = "_xiansuo";
         $node->body['und'][0]['value'] = $new->content;
         $node->field_shimin['und'][0]['value'] = $new->name;
         $node->uid = 1;
         $node->language = 'zh-hans';
         $node->status = 1;
         //(1 or 0): published or not
         $node->promote = 0;
         //(1 or 0): promoted to front page
         $node->comment = 2;
         // 0 = comments disabled, 1 = read only, 2 = read/write
         if ($new->img1 != "") {
             $suoluetu = 'e://wamp/www/epaper/assets/bl/b_' . $new->img1;
             $file = (object) array('uid' => 1, 'uri' => $suoluetu, 'filemime' => 'image/jpeg', 'status' => 1);
             $file = file_copy($file, 'public://pictures/');
             $node->field_tux['und'][0] = (array) $file;
             $htmlimg = "<div style=\"text-align: center;\"><img src=\" http://wm12.cn:88/admin/assets/img/" . $new->img1 . " \" style=\"width: 100%;\"/></div>";
             $node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value'];
         }
         $node = node_submit($node);
         // Prepare node for saving
         node_save($node);
         unset($node);
     }
 }
开发者ID:dingruoting,项目名称:tydaily,代码行数:35,代码来源:BlCommand.php


示例2: singular_settings

/**
 * Implementation of hook_settings() for themes.
 */
function singular_settings($settings)
{
    // Add js & css
    drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE);
    drupal_add_js('misc/farbtastic/farbtastic.js');
    drupal_add_js(drupal_get_path('theme', 'singular') . '/js/settings.js');
    drupal_add_css(drupal_get_path('theme', 'singular') . '/css/settings.css');
    file_check_directory(file_directory_path(), FILE_CREATE_DIRECTORY, 'file_directory_path');
    // Check for a new uploaded logo, and use that instead.
    if ($file = file_save_upload('background_file', array('file_validate_is_image' => array()))) {
        $parts = pathinfo($file->filename);
        $filename = 'singular_background.' . $parts['extension'];
        if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) {
            $settings['background_path'] = $file->filepath;
        }
    }
    $form = array();
    $form['layout'] = array('#title' => t('Layout'), '#type' => 'select', '#options' => array('fixed' => t('Fixed width'), 'fluid' => t('Fluid width')), '#default_value' => !empty($settings['layout']) ? $settings['layout'] : 'fixed');
    $form['messages'] = array('#type' => 'fieldset', '#tree' => FALSE, '#title' => t('Autoclose messages'), '#descriptions' => t('Select the message types to close automatically after a few seconds.'));
    $form['messages']['autoclose'] = array('#type' => 'checkboxes', '#options' => array('status' => t('Status'), 'warning' => t('Warning'), 'error' => t('Error')), '#default_value' => !empty($settings['autoclose']) ? $settings['autoclose'] : array('status'));
    $form['style'] = array('#title' => t('Styles'), '#type' => 'select', '#options' => singular_get_styles(), '#default_value' => !empty($settings['style']) ? $settings['style'] : 'sea');
    $form['custom'] = array('#tree' => FALSE, '#type' => 'fieldset', '#attributes' => array('class' => $form['style']['#default_value'] == 'custom' ? 'singular-custom-settings' : 'singular-custom-settings hidden'));
    $form['custom']['background_file'] = array('#type' => 'file', '#title' => t('Background image'), '#maxlength' => 40);
    if (!empty($settings['background_path'])) {
        $form['custom']['background_preview'] = array('#type' => 'markup', '#value' => !empty($settings['background_path']) ? theme('image', $settings['background_path'], NULL, NULL, array('width' => '100'), FALSE) : '');
    }
    $form['custom']['background_path'] = array('#type' => 'value', '#value' => !empty($settings['background_path']) ? $settings['background_path'] : '');
    $form['custom']['background_color'] = array('#title' => t('Background color'), '#type' => 'textfield', '#size' => '7', '#maxlength' => '7', '#default_value' => !empty($settings['background_color']) ? $settings['background_color'] : '#888888', '#suffix' => '<div id="singular-colorpicker"></div>');
    $form['custom']['background_repeat'] = array('#title' => t('Tile'), '#type' => 'select', '#options' => array('no-repeat' => t('Don\'t tile'), 'repeat-x' => t('Horizontal'), 'repeat-y' => t('Vertical'), 'repeat' => t('Both')), '#default_value' => !empty($settings['background_repeat']) ? $settings['background_repeat'] : 'no-repeat');
    return $form;
}
开发者ID:szczym,项目名称:tutturu,代码行数:34,代码来源:theme-settings.php


示例3: nuboot_radix_settings_submit

/**
 * Implements hook_setings_submit().
 */
function nuboot_radix_settings_submit($form, &$form_state)
{
    $settings = array();
    // If the user entered a path relative to the system files directory for
    // for the hero unit, store a public:// URI so the theme system can handle it.
    if (!empty($values['hero_path'])) {
        $values['hero_path'] = _system_theme_settings_validate_path($values['hero_path']);
    }
    // Get the previous value.
    $previous = $form['hero']['hero_path']['#default_value'];
    if ($previous !== 'profiles/dkan/themes/contrib/nuboot_radix/assets/images/hero.jpg') {
        $previous = 'public://' . $previous;
    } else {
        $previous = FALSE;
    }
    if ($file = file_save_upload('hero_upload')) {
        $parts = pathinfo($file->filename);
        $destination = 'public://' . $parts['basename'];
        $file->status = FILE_STATUS_PERMANENT;
        if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) {
            $_POST['hero_path'] = $form_state['values']['hero_path'] = $destination;
            // If new file has a different name than the old one, delete the old.
            if ($previous && $destination != $previous) {
                drupal_unlink($previous);
            }
        }
    } else {
        // Avoid error when the form is submitted without specifying a new image.
        $_POST['hero_path'] = $form_state['values']['hero_path'] = $previous;
    }
}
开发者ID:TwoSixtyNine,项目名称:dkan-drops-7,代码行数:34,代码来源:theme-settings.php


示例4: file_copy

/**
 * 原目录,复制到的目录
 * */
function file_copy($from, $to, $filenamearr = array())
{
    $dir = opendir($from);
    if (!is_dir($to)) {
        @mkdir($to, CREATE_DIR_MODE, true);
    }
    while (false !== ($file = readdir($dir))) {
        if (file_exists($to . '/' . $file)) {
            //continue;
        }
        if ($filenamearr) {
            if (!in_array($file, $filenamearr)) {
                continue;
            }
        }
        if ($file != '.' && $file != '..') {
            if (is_dir($from . '/' . $file)) {
                file_copy($from . '/' . $file, $to . '/' . $file, $filenamearr);
            } else {
                copy($from . '/' . $file, $to . '/' . $file);
            }
        }
    }
    closedir($dir);
}
开发者ID:h3len,项目名称:Project,代码行数:28,代码来源:functions.php


示例5: file_copy

/**
 * 原目录,复制到的目录
 * */
function file_copy($from, $to, $filenamearr = array())
{
    $status = true;
    $dir = @opendir($from);
    if (!is_dir($to)) {
        @hg_mkdir($to);
    }
    while (false !== ($file = readdir($dir))) {
        if ($filenamearr) {
            if (!in_array($file, $filenamearr)) {
                continue;
            }
        }
        if ($file != '.' && $file != '..') {
            if (is_dir($from . '/' . $file)) {
                file_copy($from . '/' . $file, $to . '/' . $file, $filenamearr);
            } else {
                if (!@copy($from . '/' . $file, $to . '/' . $file)) {
                    $status = false;
                    break;
                }
            }
        }
    }
    closedir($dir);
    return $status;
}
开发者ID:h3len,项目名称:Project,代码行数:30,代码来源:functions.php


示例6: generateImage

 public function generateImage($object, $field, $instance, $bundle)
 {
     $object_field = array();
     static $available_images = array();
     if (empty($available_images)) {
         $available_images = $this->getImages();
     }
     if (empty($available_images)) {
         $args = func_get_args();
         return call_user_func_array('_image_devel_generate', $args);
     }
     $extension = array_rand(array('jpg' => 'jpg', 'png' => 'png'));
     $min_resolution = empty($instance['settings']['min_resolution']) ? '100x100' : $instance['settings']['min_resolution'];
     $max_resolution = empty($instance['settings']['max_resolution']) ? '600x600' : $instance['settings']['max_resolution'];
     if (FALSE === ($tmp_file = drupal_tempnam('temporary://', 'imagefield_'))) {
         return FALSE;
     }
     $destination = $tmp_file . '.' . $extension;
     file_unmanaged_move($tmp_file, $destination, FILE_EXISTS_REPLACE);
     $rand_file = array_rand($available_images);
     if (!empty($instance['settings']['file_directory'])) {
         $instance['settings']['file_directory'] = $instance['settings']['file_directory'] . '/';
     }
     $destination_dir = $field['settings']['uri_scheme'] . '://' . $instance['settings']['file_directory'];
     file_prepare_directory($destination_dir, FILE_CREATE_DIRECTORY);
     if ($this->settings['devel_image_no_alter']) {
         $file = $available_images[$rand_file];
         $file = file_copy($file, $destination_dir);
     } else {
         $image = image_load($rand_file);
         $min = explode('x', $min_resolution);
         $max = explode('x', $max_resolution);
         $max[0] = $max[0] < $min[0] ? $min[0] : $max[0];
         $max[1] = $max[1] < $min[1] ? $min[1] : $max[1];
         $width = rand((int) $min[0], (int) $max[0]);
         $height = rand((int) $min[1], (int) $max[1]);
         if (!image_scale_and_crop($image, $width, $height)) {
             return FALSE;
         }
         // Use destination image type.
         $image->info['extension'] = $extension;
         if (!image_save($image, $destination)) {
             return FALSE;
         }
         $source = new stdClass();
         $source->uri = $destination;
         $source->uid = 1;
         // TODO: randomize? Use case specific.
         $source->filemime = $image->info['mime_type'];
         $source->filename = drupal_basename($image->source);
         $destination = $destination_dir . basename($destination);
         $file = file_move($source, $destination, FILE_CREATE_DIRECTORY);
     }
     $object_field['fid'] = $file->fid;
     $object_field['alt'] = devel_create_greeking(4);
     $object_field['title'] = devel_create_greeking(4);
     return $object_field;
 }
开发者ID:kreynen,项目名称:elmsln,代码行数:58,代码来源:LocalFolderProvider.class.php


示例7: actionCreate

 public function actionCreate()
 {
     if (isset($_POST['phone']) & isset($_POST['title']) & isset($_POST['content']) & isset($_POST['place']) & isset($_POST['create_time']) & isset($_POST['uid'])) {
         //用户积分修改
         $u = user_load($_POST['uid']);
         $edit = array('field_jifen' => array('und' => array(0 => array('value' => $u->field_jifen['und'][0]['value'] + 3))));
         user_save($u, $edit);
         $node->title = $_POST['title'];
         $node->field_phone['und'][0]['value'] = $_POST['phone'];
         $node->type = "sr";
         $node->body['und'][0]['value'] = $_POST['content'];
         $node->uid = $_POST['uid'];
         $node->language = 'zh-hans';
         $node->status = 0;
         //(1 or 0): published or not
         $node->promote = 0;
         //(1 or 0): promoted to front page
         $node->comment = 2;
         // 0 = comments disabled, 1 = read only, 2 = read/write
         //$node->field_riq['und'][0]['value'] =date('Y:m:d H:i:s');
         $node->field_riq['und'][0]['value'] = $_POST['create_time'];
         $node->field_src['und'][0]['value'] = $_POST['place'];
         $node->field_status['und'][0]['value'] = '处理中';
         //默认为匿名
         if (isset($_POST['name'])) {
             $node->field_shimin['und'][0]['value'] = $_POST['name'];
         }
         $image = CUploadedFile::getInstanceByName('img');
         if (is_object($image) && get_class($image) === 'CUploadedFile') {
             $dir = Yii::getPathOfAlias('webroot') . '/assets/urban/';
             //$ext = $image->getExtensionName();
             $fileName = uniqid() . '.jpg';
             $name = $dir . $fileName;
             $image->saveAs($name, true);
             $file = (object) array('uid' => $_POST['uid'], 'uri' => $name, 'filemime' => file_get_mimetype($filepath), 'status' => 1);
             $file = file_copy($file, 'public://pictures/urban');
             $node->field_tux['und'][0] = (array) $file;
         }
         $node = node_submit($node);
         // Prepare node for saving
         node_save($node);
         $basic = new basic();
         $basic->error_code = 0;
         //$basic->error_msg="no input parameters";
         $jsonObj = CJSON::encode($basic);
         echo $jsonObj;
     } else {
         $basic = new basic();
         $basic->error_code = 1;
         $basic->error_msg = "no input parameters";
         $jsonObj = CJSON::encode($basic);
         echo $jsonObj;
     }
 }
开发者ID:dingruoting,项目名称:tydaily,代码行数:54,代码来源:UrbanController.php


示例8: run

 public function run($args)
 {
     //$news=Yw::model()->findAll();
     $criteria = new CDbCriteria();
     //	$criteria->select=array('content','create_time','nick');
     //	$criteria->condition='article_id=:article_id  AND ifcheck=:ifcheck';
     $criteria->order = 'id DESC';
     //降序 最新的总是在最前面
     //	$criteria->params=array(':article_id'=>$param['id'],':ifcheck'=>'已通过');
     $news = Zt::model()->findAll($criteria);
     foreach ($news as $key => $new) {
         if ($key < 2) {
             $node = new stdClass();
             $node->title = $new->title;
             $node->body['und'][0]['value'] = $new->content;
             $node->field_fubiaoti['und'][0]['value'] = $new->subTitle;
             $node->field_src['und'][0]['value'] = $new->src;
             $node->field_label['und'][0]['value'] = $new->label;
             $node->field_myspecial['und'][0]['tid'] = 98;
             $node->uid = 1;
             $node->type = 'article';
             $node->language = 'zh-hans';
             $node->status = 1;
             //(1 or 0): published or not
             $node->promote = 0;
             //(1 or 0): promoted to front page
             $node->comment = 2;
             // 0 = comments disabled, 1 = read only, 2 = read/write
             if ($new->img3 != "") {
                 $htmlimg = "<div style=\"text-align: center;\"><img src=\" http://202.99.222.132:88/admin/assets/img/" . $new->img3 . " \" style=\"width: 100%;\"/></div>";
                 $node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value'];
             }
             if ($new->img2 != "") {
                 $htmlimg = "<div style=\"text-align: center;\"><img src=\" http://202.99.222.132:88/admin/assets/img/" . $new->img2 . " \" style=\"width: 100%;\"/></div>";
                 $node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value'];
             }
             if ($new->img1 != "") {
                 $suoluetu = 'http://202.99.222.132:88/admin/assets/img/b_' . $new->img1;
                 $file = (object) array('uid' => 1, 'uri' => $suoluetu, 'filemime' => 'image/jpeg', 'status' => 1);
                 $file = file_copy($file, 'public://pictures/');
                 $node->field_image['und'][0] = (array) $file;
                 $htmlimg = "<div style=\"text-align: center;\"><img src=\" http://202.99.222.132:88/admin/assets/img/" . $new->img1 . " \" style=\"width: 100%;\"/></div>";
                 $node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value'];
             }
             $node = node_submit($node);
             // Prepare node for saving
             //print_r($node);
             node_save($node);
         }
     }
 }
开发者ID:dingruoting,项目名称:tydaily,代码行数:51,代码来源:NewsCommand.php


示例9: testFileTokenReplacement

 /**
  * Creates a file, then tests the tokens generated from it.
  */
 function testFileTokenReplacement()
 {
     $node_storage = $this->container->get('entity.manager')->getStorage('node');
     $token_service = \Drupal::token();
     $language_interface = \Drupal::languageManager()->getCurrentLanguage();
     // Create file field.
     $type_name = 'article';
     $field_name = 'field_' . strtolower($this->randomMachineName());
     $this->createFileField($field_name, 'node', $type_name);
     $test_file = $this->getTestFile('text');
     // Coping a file to test uploads with non-latin filenames.
     $filename = drupal_dirname($test_file->getFileUri()) . '/текстовый файл.txt';
     $test_file = file_copy($test_file, $filename);
     // Create a new node with the uploaded file.
     $nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
     // Load the node and the file.
     $node_storage->resetCache(array($nid));
     $node = $node_storage->load($nid);
     $file = file_load($node->{$field_name}->target_id);
     // Generate and test sanitized tokens.
     $tests = array();
     $tests['[file:fid]'] = $file->id();
     $tests['[file:name]'] = String::checkPlain($file->getFilename());
     $tests['[file:path]'] = String::checkPlain($file->getFileUri());
     $tests['[file:mime]'] = String::checkPlain($file->getMimeType());
     $tests['[file:size]'] = format_size($file->getSize());
     $tests['[file:url]'] = String::checkPlain(file_create_url($file->getFileUri()));
     $tests['[file:created]'] = format_date($file->getCreatedTime(), 'medium', '', NULL, $language_interface->getId());
     $tests['[file:created:short]'] = format_date($file->getCreatedTime(), 'short', '', NULL, $language_interface->getId());
     $tests['[file:changed]'] = format_date($file->getChangedTime(), 'medium', '', NULL, $language_interface->getId());
     $tests['[file:changed:short]'] = format_date($file->getChangedTime(), 'short', '', NULL, $language_interface->getId());
     $tests['[file:owner]'] = String::checkPlain(user_format_name($this->adminUser));
     $tests['[file:owner:uid]'] = $file->getOwnerId();
     // Test to make sure that we generated something for each token.
     $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
     foreach ($tests as $input => $expected) {
         $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->getId()));
         $this->assertEqual($output, $expected, format_string('Sanitized file token %token replaced.', array('%token' => $input)));
     }
     // Generate and test unsanitized tokens.
     $tests['[file:name]'] = $file->getFilename();
     $tests['[file:path]'] = $file->getFileUri();
     $tests['[file:mime]'] = $file->getMimeType();
     $tests['[file:size]'] = format_size($file->getSize());
     foreach ($tests as $input => $expected) {
         $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE));
         $this->assertEqual($output, $expected, format_string('Unsanitized file token %token replaced.', array('%token' => $input)));
     }
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:52,代码来源:FileTokenReplaceTest.php


示例10: migrate

function migrate()
{
    global $term_dir;
    $completed = array();
    $names = $_POST['edit']['migrate'];
    foreach ($names as $name => $status) {
        $files = file_scan_directory($term_dir, $name);
        if (count($files) != 1) {
            print count($files) . " files match the name: {$name}";
            exit;
        }
        $image = array_pop($files);
        $image->filename_orig = $image->filename;
        if ($status == 1) {
            $image->tid = migrate_term_image_get_tid($image->name);
            if (!taxonomy_get_term($image->tid)) {
                print "cant find the tid: {$tid}";
                exit;
            }
            $t_i_image = db_fetch_object(db_query('SELECT path FROM {term_image} WHERE tid = %d', $image->tid));
            if ($t_i_image) {
                $term->has_image = true;
            }
            if ($term->has_image) {
                taxonomy_image_delete($image->tid);
            }
            if (file_copy($image->filename) != 1) {
                print "couldnt copy file: {$image->filename} to new location";
                exit;
            }
            db_query("INSERT INTO {term_image} (tid, path) VALUES (%d, '%s')", $image->tid, $image->filename);
            $completed[] = $image;
        }
        if ($_POST['edit']['delete'][$name] == 1) {
            file_delete($image->filename_orig);
            $deleted[] = $image;
        }
    }
    if ($c = count($completed)) {
        print "Updated {$c} terms";
    } else {
        print "No terms updated";
    }
    if ($c = count($deleted)) {
        print "Deleted {$c} node_image(s)";
    } else {
        print "No images deleted";
    }
}
开发者ID:nabuur,项目名称:nabuur-d5,代码行数:49,代码来源:update_term_images.php


示例11: file_copy

function file_copy($src, $des, $filter)
{
    $dir = opendir($src);
    @mkdir($des);
    while (false !== ($file = readdir($dir))) {
        if ($file != '.' && $file != '..') {
            if (is_dir($src . '/' . $file)) {
                file_copy($src . '/' . $file, $des . '/' . $file, $filter);
            } elseif (!in_array(substr($file, strrpos($file, '.') + 1), $filter)) {
                copy($src . '/' . $file, $des . '/' . $file);
            }
        }
    }
    closedir($dir);
}
开发者ID:ChainBoy,项目名称:wxfx,代码行数:15,代码来源:file.func.php


示例12: test_file

 public function test_file()
 {
     $file1 = self::getDir() . '/dir1/foo.txt';
     $file2 = self::getDir() . '/dir2/bar.txt';
     $file3 = self::getDir() . '/dir2/baz.txt';
     $file3_name = 'baz.txt';
     $file4 = self::getDir() . '/dir4/yolo.txt';
     $this->assertFalse(file_exists($file1));
     file_create($file1);
     file_write($file1, '');
     $this->assertTrue(file_exists($file1));
     $this->assertEquals('', file_read($file1));
     file_write($file1, 'foo');
     $this->assertEquals('foo', file_read($file1));
     file_append($file1, '_bar');
     $this->assertEquals('foo_bar', file_read($file1));
     file_prepend($file1, '#');
     $this->assertEquals('#foo_bar', file_read($file1));
     file_append($file1, '_bar');
     file_prepend($file1, '#');
     $this->assertEquals('##foo_bar_bar', file_read($file1));
     file_append($file1 . '_append', '_bar');
     $this->assertEquals(file_read($file1 . '_append'), '_bar');
     file_prepend($file1 . '_prepend', '#');
     $this->assertEquals(file_read($file1 . '_prepend'), '#');
     $this->assertFalse(file_exists($file2));
     file_copy($file1, $file2);
     $this->assertTrue(file_exists($file2));
     $this->assertEquals(file_read($file1), file_read($file2));
     $this->assertFalse(file_exists($file3));
     file_rename($file2, $file3_name);
     $this->assertFalse(file_exists($file2));
     $this->assertTrue(file_exists($file3));
     $this->assertEquals(file_read($file1), file_read($file3));
     $this->assertFalse(file_exists($file4));
     file_move($file3, $file4);
     $this->assertFalse(file_exists($file3));
     $this->assertTrue(file_exists($file4));
     $this->assertEquals(file_read($file1), file_read($file4));
     file_delete($file4);
     file_delete($file4);
     $this->assertFalse(file_exists($file4));
     $this->assertEquals(self::getDir() . '/dir1', file_get_directory($file1));
     $this->assertEquals('txt', file_get_extension($file1));
     $this->assertEquals('foo.txt', file_get_name($file1));
 }
开发者ID:weew,项目名称:helpers-filesystem,代码行数:46,代码来源:FileTest.php


示例13: intranet_system_theme_settings_submit

function intranet_system_theme_settings_submit($form, &$form_state)
{
    $settings = array();
    $file = file_save_upload('footer_image_upload');
    $bg_imags = array('bg_image_upload' => 'bg_image_path', 'header_image_upload' => 'header_image_path', 'footer_image_upload' => 'footer_image_path');
    foreach ($bg_imags as $upload => $path) {
        // Check for a new uploaded file, and use that if available.
        if ($file = file_save_upload($upload)) {
            $parts = pathinfo($file->filename);
            $destination = 'public://' . $parts['basename'];
            $file->status = FILE_STATUS_PERMANENT;
            if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) {
            }
            $form_state['values'][$path] = $destination;
        }
    }
}
开发者ID:cap-mayank,项目名称:intranet,代码行数:17,代码来源:theme-settings.php


示例14: open_framework_settings_submit

function open_framework_settings_submit($form, &$form_state)
{
    $settings = array();
    // Get the previous value
    $previous = 'public://' . $form['background_container']['body_bg_path']['#default_value'];
    $file = file_save_upload('body_bg_upload');
    if ($file) {
        $parts = pathinfo($file->filename);
        $destination = 'public://' . $parts['basename'];
        $file->status = FILE_STATUS_PERMANENT;
        if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) {
            $_POST['body_bg_path'] = $form_state['values']['body_bg_path'] = $destination;
        }
    } else {
        // Avoid error when the form is submitted without specifying a new image
        $_POST['body_bg_path'] = $form_state['values']['body_bg_path'] = $previous;
    }
}
开发者ID:Arabidopsis-Information-Portal,项目名称:araport-portal,代码行数:18,代码来源:theme-settings.php


示例15: add_datastream_from_file

 function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = null, $datastream_mimetype = '', $controlGroup = 'M')
 {
     module_load_include('php', 'fedora_repository', 'mimetype');
     if (empty($datastream_mimetype)) {
         // Get mime type from the file extension.
         $mimetype_helper = new mimetype();
         $datastream_mimetype = $mimetype_helper->getType($datastream_file);
     }
     $original_path = $datastream_file;
     // Temporarily move file to a web-accessible location.
     file_copy($datastream_file, file_directory_path());
     $datastream_url = drupal_urlencode($datastream_file);
     $url = file_create_url($datastream_url);
     $return_value = $this->add_datastream_from_url($url, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup);
     if ($original_path != $datastream_file) {
         file_delete($datastream_file);
     }
     return $return_value;
 }
开发者ID:ratzeni,项目名称:islandora,代码行数:19,代码来源:fedora_item.php


示例16: hosting_themes_settings_submit

function hosting_themes_settings_submit($form, &$form_state)
{
    // Get the previous value
    $previous = 'public://' . $form['contact']['contact_icon']['#default_value'];
    $file = file_save_upload('contact_icon_upload');
    if ($file) {
        $parts = pathinfo($file->filename);
        $destination = 'public://' . $parts['basename'];
        $file->status = FILE_STATUS_PERMANENT;
        if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) {
            $_POST['contact_icon'] = $form_state['values']['contact_icon'] = $destination;
            if ($destination != $previous) {
                return;
            }
        }
    } else {
        // Avoid error when the form is submitted without specifying a new image
        $_POST['contact_icon'] = $form_state['values']['contact_icon'] = $previous;
    }
}
开发者ID:henrytran9x,项目名称:hosting,代码行数:20,代码来源:theme-settings.php


示例17: actionCreate

 public function actionCreate()
 {
     if (isset($_POST['phone']) & isset($_POST['title']) & isset($_POST['content']) & isset($_POST['place']) & isset($_POST['create_time'])) {
         $node->title = $_POST['title'];
         $node->field_phone['und'][0]['value'] = $_POST['phone'];
         $node->type = "sr";
         $node->body['und'][0]['value'] = $_POST['content'];
         $node->uid = 1;
         $node->language = 'zh-hans';
         $node->status = 0;
         //(1 or 0): published or not
         $node->promote = 0;
         //(1 or 0): promoted to front page
         $node->comment = 2;
         // 0 = comments disabled, 1 = read only, 2 = read/write
         $node->field_riq['und'][0]['value'] = date('Y:m:d H:i:s');
         $node->field_src['und'][0]['value'] = $_POST['place'];
         $node->field_status['und'][0]['value'] = '处理中';
         if (isset($_POST['name'])) {
             $node->field_shimin['und'][0]['value'] = $_POST['name'];
         }
         $image = CUploadedFile::getInstanceByName('img');
         if (is_object($image) && get_class($image) === 'CUploadedFile') {
             $dir = Yii::getPathOfAlias('webroot') . '/assets/pic/';
             //$ext = $image->getExtensionName();
             $fileName = uniqid() . '.jpg';
             $name = $dir . $fileName;
             $image->saveAs($name, true);
             $file = (object) array('uid' => 1, 'uri' => $name, 'filemime' => file_get_mimetype($filepath), 'status' => 1);
             $file = file_copy($file, 'public://pictures/');
             $node->field_tux['und'][0] = (array) $file;
         }
         $node = node_submit($node);
         // Prepare node for saving
         node_save($node);
         echo '1';
     } else {
         echo '0';
     }
 }
开发者ID:dingruoting,项目名称:tydaily,代码行数:40,代码来源:MsController.php


示例18: academy_settings_submit

function academy_settings_submit($form, &$form_state)
{
    $settings = array();
    // Get the previous value
    $previous = 'public://' . $form['bg_image']['bg_path']['#default_value'];
    $file = file_save_upload('bg_upload');
    if ($file) {
        $parts = pathinfo($file->filename);
        $destination = 'public://' . $parts['basename'];
        $file->status = FILE_STATUS_PERMANENT;
        if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) {
            $_POST['bg_path'] = $form_state['values']['bg_path'] = $destination;
            // If new file has a different name than the old one, delete the old
            if ($destination != $previous) {
                drupal_unlink($previous);
            }
        }
    } else {
        // Avoid error when the form is submitted without specifying a new image
        $_POST['bg_path'] = $form_state['values']['bg_path'] = $previous;
    }
}
开发者ID:EWB,项目名称:grh,代码行数:22,代码来源:theme-settings.php


示例19: createContentFromImage

/**
 * Funzione che consente di creare automaticamente un contenuto drupal con le immagini jpg caricate in temp_img
 * e i dati exif ricavati da esse.
 *
 * @param $lat
 * @param $lng
 * @param $fileName
 *
 */
function createContentFromImage($lat, $lng, $fileName)
{
    $node = new stdClass();
    // Create a new node object Or page, or whatever content type you like
    $node->type = "exif_data";
    // Set some default values
    node_object_prepare($node);
    $node->language = "en";
    $node->uid = 1;
    $coords = (object) array('lat' => $lat, 'lng' => $lng);
    $node->field_posizione['und'][0] = (array) $coords;
    //@ToDo here you have to substitute the path
    $file_path = "/var/www/.." . $fileName;
    $count_photo = count($file_path);
    for ($i = 0; $i < $count_photo; $i++) {
        if (getimagesize($file_path)) {
            $file_gallery = (object) array('uid' => 0, 'uri' => $file_path, 'filemime' => file_get_mimetype($file_path), 'status' => 1);
            //substitute "your_destination_folder" with a folder name
            try {
                file_copy($file_gallery, 'public://your_destination_folder');
                $node->field_image['und'][0] = (array) $file_gallery;
                echo "File correctly copied";
            } catch (Exception $e) {
                echo $e->getMessage();
            }
        }
    }
    //$node = node_submit($node); // Prepare node for saving
    if ($node = node_submit($node)) {
        // Prepare node for saving
        node_save($node);
        //Drupal node saving function call
        $status = "Content created correctly" . "";
    } else {
        $status = "Something went wrong during the node submitting";
    }
    echo $status;
}
开发者ID:marshall86,项目名称:Drupal-content-generator,代码行数:47,代码来源:contentGenerator.php


示例20: save

 function save()
 {
     include load('include.lang');
     if (!$this->is_allow()) {
         return $this->_($L['upload_not_allow']);
     }
     $this->set_savepath($this->savepath);
     $this->set_savename($this->savename);
     if (file_copy($this->file, DT_ROOT . '/' . $this->saveto)) {
         if (!@getimagesize(DT_ROOT . '/' . $this->saveto)) {
             file_del(DT_ROOT . '/' . $this->saveto);
             return $this->_($L['upload_bad']);
         }
         if ($this->maxsize > 0 && filesize(DT_ROOT . '/' . $this->saveto) > $this->maxsize) {
             file_del(DT_ROOT . '/' . $this->saveto);
             return $this->_($L['upload_size_limit'] . ' (' . intval($this->maxsize / 1024) . 'Kb)');
         }
         $this->image = 1;
         return true;
     } else {
         return $this->_($L['upload_failed']);
     }
 }
开发者ID:hcd2008,项目名称:destoon,代码行数:23,代码来源:remote.class.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP file_correct_filepath函数代码示例发布时间:2022-05-15
下一篇:
PHP file_check_directory函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap