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


PHP get_uploaded_file函数代码示例

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


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

示例1: izap_upload_generate_thumbs

 /**
  *
  * @param <string> $filearray    # $_FILES array posted from your form
  * @param <string> $location     # location of the file you want to save in. This is with respect to home of the user in file matrix.
  * @param <array>  $thumbsarray  # Array of thumbs you want to create
  */
 public function izap_upload_generate_thumbs($filearray, $thumbsarray = array('tiny' => '25', 'small' => '40', 'medium' => '100x100', 'large' => '200x200', 'master' => '550x550'), $location = false)
 {
     $location = !$location ? strtolower(get_class($this)) . '/' : $location;
     foreach ($filearray as $fkey => $fvalue) {
         $fieldname = $fkey;
         $original_name = $fvalue['name'];
         $type = $fvalue['type'];
     }
     $filename = $this->izap_remove_special_characters($original_name);
     $this->setFilename($location . $filename);
     $this->open('write');
     $this->write(get_uploaded_file($fieldname));
     $this->close();
     $stored_file = $this->getFilenameOnFilestore();
     $array_to_be_stored = array('file_name' => $filename, 'file_type' => $type);
     if ($thumbsarray) {
         foreach ($thumbsarray as $key => $val) {
             $size = preg_split('/[Xx]/', $val);
             $thumb_index = strtolower(is_string($key) ? $key : $val);
             $thumb_name = $thumb_index . "_" . $filename;
             $thumbnail = get_resized_image_from_existing_file($stored_file, $size[0], $size[1] ? $size[1] : $size[0], $size[1] ? false : true);
             $this->setFilename($location . $thumb_name);
             if ($this->open("write")) {
                 $this->write($thumbnail);
                 $thumbs[$thumb_index] = $thumb_name;
             }
             $this->close();
         }
         $array_to_be_stored['thumbs'] = $thumbs;
     }
     $this->{$fieldname} = serialize($array_to_be_stored);
 }
开发者ID:socialweb,项目名称:PiGo,代码行数:38,代码来源:ZContest.php

示例2: saveArchive

 public function saveArchive($name)
 {
     $uf = get_uploaded_file($name);
     if (!$uf) {
         return FALSE;
     }
     $this->open("write");
     $this->write($uf);
     $this->close();
     return true;
 }
开发者ID:lorea,项目名称:Hydra-dev,代码行数:11,代码来源:PluginRelease.php

示例3: savePluginFile

 public function savePluginFile($name)
 {
     $uf = get_uploaded_file($name);
     if (!$uf) {
         return FALSE;
     }
     $this->open("write");
     $this->write($uf);
     $this->close();
     return TRUE;
 }
开发者ID:nohup,项目名称:community_plugins,代码行数:11,代码来源:PluginRelease.php

示例4: openFile

 /**
  * Process the file
  *
  * @param $file
  * @return boolean
  */
 function openFile($file)
 {
     if (!($contents = get_uploaded_file($file))) {
         register_error(elgg_echo('upload_users:error:cannot_open_file'));
         return false;
     }
     /// Check the encoding
     if ($this->encoding == 'ISO-8859-1') {
         $contents = utf8_encode($contents);
     }
     $this->raw_data = $contents;
     return true;
 }
开发者ID:socialweb,项目名称:PiGo,代码行数:19,代码来源:UploadUsers.php

示例5: uploadCK

function uploadCK($page, $identifier, $obj)
{
    $funcNum2 = get_Input('CKEditorFuncNum', 'CKEditorFuncNum');
    $file = new ElggFile();
    $filestorename = strtolower(time() . $_FILES['upload']['name']);
    $file->setFilename($filestorename);
    $file->setMimeType($_FILES['upload']['type']);
    $file->owner_guid = elgg_get_logged_in_user_guid();
    $file->subtype = "file";
    $file->originalfilename = $filestorename;
    $file->access_id = ACCESS_PUBLIC;
    $file->open("write");
    $file->write(get_uploaded_file('upload'));
    $file->close();
    $result = $file->save();
    if ($result) {
        $master = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 550, 550);
        if ($master !== false) {
            $_SESSION['UPLOAD_DATA']['file_save'] = "started";
            $filehandler = new ElggFile();
            $filehandler->setFilename($filestorename);
            $filehandler->setMimeType($_FILES['upload']['type']);
            $filehandler->owner_guid = $user->guid;
            $filehandler->subtype = "file";
            $filehandler->originalfilename = $filestorename;
            $filehandler->access_id = ACCESS_PUBLIC;
            $filehandler->open("write");
            $filehandler->write($master);
            $filehandler->close();
            $filehandler->save();
            // Dev URL
            $url = elgg_get_site_url() . 'CKEditorView?file_guid=' . $filehandler->guid;
            //Production URL
            //$url ='/CKEditorView?file_guid='.$filehandler->guid;
            echo '<script type="text/javascript">
		window.parent.CKEDITOR.tools.callFunction(' . $funcNum2 . ', "' . $url . '","");
		</script>';
            exit;
        } else {
            echo '<script type="text/javascript">
		window.parent.CKEDITOR.tools.callFunction(' . $funcNum2 . ', "","");
		</script>';
            exit;
        }
    }
    return true;
}
开发者ID:socialweb,项目名称:PiGo,代码行数:47,代码来源:start.php

示例6: saveImage

 public function saveImage($name, $title, $index)
 {
     if ($_FILES[$name]['error'] != 0) {
         return FALSE;
     }
     $info = $_FILES[$name];
     // delete original image if exists
     $options = array('relationship_guid' => $this->getGUID(), 'relationship' => 'image', 'metadata_name_value_pair' => array('name' => 'project_image', 'value' => "{$index}"));
     if ($old_image = elgg_get_entities_from_relationship($options)) {
         if ($old_image[0] instanceof ElggFile) {
             $old_image[0]->delete();
         }
     }
     $image = new ElggFile();
     $prefix = "plugins/";
     $store_name_base = $prefix . strtolower($this->getGUID() . "_{$name}");
     $image->title = $title;
     $image->access_id = $this->access_id;
     $image->setFilename($store_name_base . '.jpg');
     $image->setMimetype('image/jpeg');
     $image->originalfilename = $info['name'];
     $image->project_image = $index;
     // used for deletion on replacement
     $image->save();
     $uf = get_uploaded_file($name);
     if (!$uf) {
         return FALSE;
     }
     $image->open("write");
     $image->write($uf);
     $image->close();
     add_entity_relationship($this->guid, 'image', $image->guid);
     // create a thumbnail
     if ($this->saveThumbnail($image, $store_name_base . '_thumb.jpg') != TRUE) {
         $image->delete();
         return FALSE;
     }
     return TRUE;
 }
开发者ID:nohup,项目名称:community_plugins,代码行数:39,代码来源:PluginProject.php

示例7: newsletter_process_csv_upload

/**
 * Process an uploaded CSV file to find new recipients.
 *
 * @param array $recipients previous recipients, to prevent duplicates
 * Contains:
 *
 * user_guids => array() existing users
 * emails => array() extra email addresses
 *
 * @return array
 */
function newsletter_process_csv_upload(array $recipients)
{
    // is a file uploaded
    if (get_uploaded_file("csv")) {
        // open the file as CSV
        $fh = fopen($_FILES["csv"]["tmp_name"], "r");
        if (!empty($fh)) {
            $email_column = false;
            // try to find an email column (in the first 2 rows)
            for ($i = 0; $i < 2; $i++) {
                $row = fgetcsv($fh, null, ";", "\"");
                if ($row) {
                    foreach ($row as $index => $field) {
                        if (newsletter_is_email_address($field)) {
                            $email_column = $index;
                            break;
                        }
                    }
                }
            }
            // found an email column
            if ($email_column !== false) {
                $counter = 0;
                // start at the beginning
                if (rewind($fh)) {
                    $row = fgetcsv($fh, null, ";", "\"");
                    while ($row !== false) {
                        // get the email address
                        $email = @$row[$email_column];
                        // make sure it's a valid email address
                        if (newsletter_is_email_address($email)) {
                            $counter++;
                            $exists = false;
                            // is this email address already in the recipients list
                            if (in_array($email, $recipients["emails"])) {
                                $exists = true;
                            } else {
                                // check for an existing user
                                $ia = elgg_set_ignore_access(true);
                                $users = get_user_by_email($email);
                                if (!empty($users)) {
                                    foreach ($users as $user) {
                                        if (in_array($user->getGUID(), $recipients["user_guids"])) {
                                            $exists = true;
                                        }
                                    }
                                }
                                elgg_set_ignore_access($ia);
                            }
                            if ($exists === false) {
                                // email address wasn't added yet
                                // so add to the list
                                $ia = elgg_set_ignore_access(true);
                                $users = get_user_by_email($email);
                                if (!empty($users)) {
                                    $recipients["user_guids"][] = $users[0]->getGUID();
                                } else {
                                    $recipients["emails"][] = $email;
                                }
                                elgg_set_ignore_access($ia);
                            }
                        }
                        // go to the next row
                        $row = fgetcsv($fh, null, ";", "\"");
                    }
                    // done, report the added emails
                    system_message(elgg_echo("newsletter:csv:added", array($counter)));
                }
            } else {
                // no email column found, report this
                system_message(elgg_echo("newsletter:csv:no_email"));
            }
        }
    }
    return $recipients;
}
开发者ID:pleio,项目名称:newsletter,代码行数:87,代码来源:functions.php

示例8: get_input

<?php

$container_guid = (int) get_input('container_guid', 0);
$parent_guid = get_input('parent_guid');
set_time_limit(0);
$forward_url = REFERER;
if (empty($container_guid) || !get_uploaded_file('zip_file')) {
    register_error(elgg_echo('file:cannotload'));
    forward(REFERER);
}
$extension_array = explode('.', $_FILES['zip_file']['name']);
if (strtolower(end($extension_array)) !== 'zip') {
    register_error(elgg_echo('file:uploadfailed'));
    forward(REFERER);
}
$file = $_FILES['zip_file'];
// disable notifications of new objects
elgg_unregister_notification_event('object', 'file');
if (file_tools_unzip($file, $container_guid, $parent_guid)) {
    system_message(elgg_echo('file:saved'));
    $container = get_entity($container_guid);
    if ($container instanceof ElggGroup) {
        $forward_url = "file/group/{$container->getGUID()}/all#{$parent_guid}";
    } else {
        $forward_url = "file/owner/{$container->username}#{$parent_guid}";
    }
} else {
    register_error(elgg_echo('file:uploadfailed'));
}
// reenable notifications of new objects
elgg_register_notification_event('object', 'file');
开发者ID:coldtrick,项目名称:file_tools,代码行数:31,代码来源:zip.php

示例9: elgg_set_page_owner_guid

// group creator needs to be member of new group and river entry created
if ($is_new_group) {
    // @todo this should not be necessary...
    elgg_set_page_owner_guid($group->guid);
    $group->join($user);
    add_to_river('river/group/create', 'create', $user->guid, $group->guid, $group->access_id);
}
$has_uploaded_icon = !empty($_FILES['icon']['type']) && substr_count($_FILES['icon']['type'], 'image/');
if ($has_uploaded_icon) {
    $icon_sizes = elgg_get_config('icon_sizes');
    $prefix = "groups/" . $group->guid;
    $filehandler = new ElggFile();
    $filehandler->owner_guid = $group->owner_guid;
    $filehandler->setFilename($prefix . ".jpg");
    $filehandler->open("write");
    $filehandler->write(get_uploaded_file('icon'));
    $filehandler->close();
    $filename = $filehandler->getFilenameOnFilestore();
    $sizes = array('tiny', 'small', 'medium', 'large');
    $thumbs = array();
    foreach ($sizes as $size) {
        $thumbs[$size] = get_resized_image_from_existing_file($filename, $icon_sizes[$size]['w'], $icon_sizes[$size]['h'], $icon_sizes[$size]['square']);
    }
    if ($thumbs['tiny']) {
        // just checking if resize successful
        $thumb = new ElggFile();
        $thumb->owner_guid = $group->owner_guid;
        $thumb->setMimeType('image/jpeg');
        foreach ($sizes as $size) {
            $thumb->setFilename("{$prefix}{$size}.jpg");
            $thumb->open("write");
开发者ID:duanhv,项目名称:mdg-social,代码行数:31,代码来源:edit.php

示例10: tempnam

<?php

$forward_url = REFERER;
if (($csv = get_uploaded_file("csv")) && !empty($csv)) {
    $tmp_location = $_FILES["csv"]["tmp_name"];
    if ($fh = fopen($tmp_location, "r")) {
        if (($data = fgetcsv($fh, 0, ";")) !== false) {
            $new_location = tempnam(sys_get_temp_dir(), "subsite_import_" . get_config("site_guid"));
            move_uploaded_file($tmp_location, $new_location);
            $_SESSION["subsite_manager_import"] = array("location" => $new_location, "sample" => $data);
            $forward_url = elgg_get_site_url() . "admin/users/import?step=2";
            system_message(elgg_echo("subsite_manager:action:import:step1:success"));
        } else {
            register_error(elgg_echo("subsite_manager:action:import:step1:error:content"));
        }
    } else {
        register_error(elgg_echo("subsite_manager:action:import:step1:error:file"));
    }
} else {
    register_error(elgg_echo("subsite_manager:action:import:step1:error:csv"));
}
forward($forward_url);
开发者ID:pleio,项目名称:subsite_manager,代码行数:22,代码来源:step1.php

示例11: get_input

 $error = false;
 //timelinefile
 // if use current
 if (get_input('timeline-image')) {
     $image = get_input('timeline-image');
     // custom image?
     // right file type and not to big?
     if ($image == 'customtimeline') {
         if (substr_count($_FILES['timelinefile']['type'], 'image/') && isset($_FILES['timelinefile']) && $_FILES['timelinefile']['error'] == 0) {
             $filename = "customtimeline";
             $extension = pathinfo($_FILES['timelinefile']['name']);
             $extension = $extension['extension'];
             $filehandler = new ElggFile();
             $filehandler->setFilename($filename);
             $filehandler->open("write");
             $filehandler->write(get_uploaded_file('timelinefile'));
             $filehandler->close();
             $thumbnail = new ElggFile();
             $thumbnail->setFilename($filename . "_thumb");
             $thumbnail->open("write");
             $thumbnail->write(get_resized_image_from_uploaded_file('timelinefile', 150, 150, false));
             $thumbnail->close();
             $timelineURL = 'pg/timeline_theme/getbackground?id=' . $current_user;
         } else {
             register_error(elgg_echo('timelinestyle:timeline:error:image'));
             forward($_SERVER['HTTP_REFERER']);
         }
     } else {
         $timelineURL = $image;
     }
     if (create_metadata($timelinestyle_object->guid, 'timeline-image', $timelineURL, 'string', $_SESSION['guid'], $access_id) == false || empty($timelineURL)) {
开发者ID:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:31,代码来源:savebackground.php

示例12: image_data

/**
 * Uploads an image.
 *
 * Can be used to upload a new image or replace an existing one.
 * If $id is specified, the image will be replaced. If $uploaded is set FALSE,
 * $file can take a local file instead of HTTP file upload variable.
 *
 * All uploaded files will included on the Images panel.
 *
 * @param   array        $file     HTTP file upload variables
 * @param   array        $meta     Image meta data, allowed keys 'caption', 'alt', 'category'
 * @param   int          $id       Existing image's ID
 * @param   bool         $uploaded If FALSE, $file takes a filename instead of upload vars
 * @return  array|string An array of array(message, id) on success, localized error string on error
 * @package Image
 * @example
 * print_r(image_data(
 *     $_FILES['myfile'],
 *     array(
 *         'caption' => '',
 *         'alt' => '',
 *         'category' => '',
 *     )
 * ));
 */
function image_data($file, $meta = array(), $id = 0, $uploaded = true)
{
    global $txp_user, $event;
    $name = $file['name'];
    $error = $file['error'];
    $file = $file['tmp_name'];
    if ($uploaded) {
        $file = get_uploaded_file($file);
        if (get_pref('file_max_upload_size') < filesize($file)) {
            unlink($file);
            return upload_get_errormsg(UPLOAD_ERR_FORM_SIZE);
        }
    }
    if (empty($file)) {
        return upload_get_errormsg(UPLOAD_ERR_NO_FILE);
    }
    list($w, $h, $extension) = getimagesize($file);
    $ext = get_safe_image_types($extension);
    if (!$ext) {
        return gTxt('only_graphic_files_allowed');
    }
    $name = substr($name, 0, strrpos($name, '.')) . $ext;
    $safename = doSlash($name);
    $meta = lAtts(array('category' => '', 'caption' => '', 'alt' => ''), (array) $meta, false);
    extract(doSlash($meta));
    $q = "\n        name = '{$safename}',\n        ext = '{$ext}',\n        w = {$w},\n        h = {$h},\n        alt = '{$alt}',\n        caption = '{$caption}',\n        category = '{$category}',\n        date = now(),\n        author = '" . doSlash($txp_user) . "'\n    ";
    if (empty($id)) {
        $rs = safe_insert('txp_image', $q);
        if ($rs) {
            $id = $GLOBALS['ID'] = $rs;
        }
        $update = false;
    } else {
        $id = assert_int($id);
        $rs = safe_update('txp_image', $q, "id = {$id}");
        $update = true;
    }
    if (!$rs) {
        return gTxt('image_save_error');
    }
    $newpath = IMPATH . $id . $ext;
    if (shift_uploaded_file($file, $newpath) == false) {
        if (!$update) {
            safe_delete('txp_image', "id = {$id}");
        }
        unset($GLOBALS['ID']);
        return $newpath . sp . gTxt('upload_dir_perms');
    }
    @chmod($newpath, 0644);
    // GD is supported
    if (check_gd($ext)) {
        // Auto-generate a thumbnail using the last settings
        if (get_pref('thumb_w') > 0 || get_pref('thumb_h') > 0) {
            $t = new txp_thumb($id);
            $t->crop = (bool) get_pref('thumb_crop');
            $t->hint = '0';
            $t->width = (int) get_pref('thumb_w');
            $t->height = (int) get_pref('thumb_h');
            $t->write();
        }
    }
    $message = gTxt('image_uploaded', array('{name}' => $name));
    update_lastmod('image_uploaded', compact('id', 'name', 'ext', 'w', 'h', 'alt', 'caption', 'category', 'txpuser'));
    // call post-upload plugins with new image's $id
    callback_event('image_uploaded', $event, false, $id);
    return array($message, $id);
}
开发者ID:hcgtv,项目名称:textpattern,代码行数:92,代码来源:txplib_misc.php

示例13: elgg_extract

<?php

$file_input = elgg_extract('file', $_FILES);
$filename = $file_input['name'];
if (empty($filename) || elgg_extract('error', $file_input) !== 0) {
    register_error(elgg_echo('upload:error:unknown'));
    forward(REFERER);
}
$file = new \AssetFile();
$file->setFilename('asset_library/' . $filename);
$file->open('write');
$file->write(get_uploaded_file('file'));
$file->close();
$file->save();
$file->mimetype = (new \Elgg\Filesystem\MimeTypeDetector())->getType($file->getFilenameOnFilestore(), $file->getMimeType());
$file->simpletype = elgg_get_file_simple_type($file->mimetype);
$file->save();
forward(REFERER);
开发者ID:coldtrick,项目名称:asset_library,代码行数:18,代码来源:upload.php

示例14: admin_gatekeeper

<?php

/**
 * Plugin Installer - installer
 * 
 * @package plugin_installer
 * @author ColdTrick IT Solutions
 * @copyright Coldtrick IT Solutions 2009
 * @link http://www.coldtrick.com/
 */
// Make sure action is secure
admin_gatekeeper();
action_gatekeeper();
$package = get_uploaded_file('module_package');
$overwrite = get_input('overwrite', false);
if ($package) {
    global $CONFIG;
    $filename = time() . $_FILES['module_package']['name'];
    $filehandler = new ElggFile();
    $filehandler->setFilename($filename);
    $filehandler->open("write");
    $filehandler->write($package);
    $zip = new ZipArchive();
    $res = $zip->open($filehandler->getFilenameOnFilestore());
    if ($res === TRUE) {
        $plugin_name = false;
        $manifest = false;
        $start = false;
        for ($i = 0; $i < $zip->numFiles; $i++) {
            $entry = $zip->statIndex($i);
            if (stristr($entry['name'], "manifest.xml") && substr_count($entry['name'], "/") == 1) {
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:31,代码来源:install.php

示例15: get_input

 $error = false;
 //backgroundfile
 // if use current
 if (get_input('background-image')) {
     $image = get_input('background-image');
     // custom image?
     // right file type and not to big?
     if ($image == 'custombackground') {
         if (substr_count($_FILES['backgroundfile']['type'], 'image/') && isset($_FILES['backgroundfile']) && $_FILES['backgroundfile']['error'] == 0) {
             $filename = "custombackground";
             $extension = pathinfo($_FILES['backgroundfile']['name']);
             $extension = $extension['extension'];
             $filehandler = new ElggFile();
             $filehandler->setFilename($filename);
             $filehandler->open("write");
             $filehandler->write(get_uploaded_file('backgroundfile'));
             $filehandler->close();
             $thumbnail = new ElggFile();
             $thumbnail->setFilename($filename . "_thumb");
             $thumbnail->open("write");
             $thumbnail->write(get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), 150, 150, false));
             $thumbnail->close();
             $backgroundURL = 'mod/customstyle/getbackground?id=' . $current_user;
         } else {
             register_error(elgg_echo('customstyle:background:error:image'));
             forward($_SERVER['HTTP_REFERER']);
         }
     } else {
         $backgroundURL = $image;
     }
     if (create_metadata($customstyle_object->guid, 'background-image', $backgroundURL, 'string', $_SESSION['guid'], $access_id) == false || empty($backgroundURL)) {
开发者ID:Ruthkaveke,项目名称:tumchat,代码行数:31,代码来源:savebackground.php


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