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


PHP FileUploader::upload_file方法代码示例

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


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

示例1: FileUploader

 function handle_uploaded_avatar_pic()
 {
     if (isset($_POST['user_filename'])) {
         $_POST['user_filename'] = Storage::validateFileId($_POST['user_filename']);
     }
     if (!empty($_FILES['userfile']['name'])) {
         // process uploaded image file
         $myUploadobj = new FileUploader();
         $file = $myUploadobj->upload_file(PA::$upload_path, 'userfile', true, true, 'image');
         if (!$file) {
             throw new PAException(FILE_NOT_UPLOADED, $myUploadobj->error);
         }
     } else {
         // download given image url
         $avatar_url = trim(@$_REQUEST['avatar_url']);
         if (!empty($avatar_url) && preg_match("|http://(.*?)/(.*)|", $avatar_url, $m)) {
             list(, $uf_server, $uf_path) = $m;
             $file = Storage::save($avatar_url, basename($uf_path), "critical", "image");
             if (!$file) {
                 throw new PAException(FILE_NOT_UPLOADED, sprintf(__("Could not retrieve file from URL: %s"), $avatar_url));
             }
         }
     }
     if (@$file) {
         $_POST['user_filename'] = $file;
         $_POST['avatar_url'] = '';
     }
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:28,代码来源:RegistrationPage.php

示例2: header_image

function header_image()
{
    $header_image_action = $_POST['header_image_option'];
    $display_header_image = $_POST['desktop_image_display'];
    if (!empty($_FILES['headerphoto']['name']) && empty($_POST['restore_default'])) {
        $uploadfile = PA::$upload_path . basename($_FILES['headerphoto']['name']);
        $myUploadobj = new FileUploader();
        //creating instance of file.
        $image_type = 'image';
        $file = $myUploadobj->upload_file(PA::$upload_path, 'headerphoto', true, true, $image_type);
        if ($file == false) {
            throw new PAException(GROUP_PARAMETER_ERROR, "File upload error: " . $myUploadobj->error);
        }
        $header_image = $file;
        $header_img = array('display_header_image' => $display_header_image, 'header_image_action' => $header_image_action, 'header_image' => $header_image);
        return $header_img;
    }
    if (isset($_POST['restore_default'])) {
        $header_image = NULL;
        $header_img = array('display_header_image' => $display_header_image, 'header_image_action' => $header_image_action, 'header_image' => $header_image);
        return $header_img;
    }
    $header_img = array('display_header_image' => $display_header_image, 'header_image_action' => $header_image_action);
    return $header_img;
}
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:25,代码来源:group_functions.php

示例3: basename

 function handle_uploaded_avatar_pic()
 {
     if (!empty($_FILES['userfile']['name'])) {
         $uploadfile = PA::$upload_path . basename($_FILES['userfile']['name']);
         $myUploadobj = new FileUploader();
         //creating instance of file.
         $image_type = 'image';
         $file = $myUploadobj->upload_file(PA::$upload_path, 'userfile', true, true, $image_type);
         if ($file == false) {
             $this->reg_user->msg = $myUploadobj->error;
             $this->reg_user->error = TRUE;
         } else {
             $_POST['user_filename'] = $file;
         }
     } else {
         // IF THE UPLOAD FIELD WAS EMPTY CHECK FOR THE URL FIELD
         $avatar_url = trim(@$_REQUEST['avatar_url']);
         if (!empty($avatar_url) && preg_match("|http://(.*?)/(.*)|", $avatar_url, $m)) {
             //TODO: change to use FileUploader or new storage code.
             list(, $uf_server, $uf_path) = $m;
             $uf_basename = preg_replace("[^A-Za-z0-9\\-_\\.]", "_", basename($uf_path));
             //FETCH THE IMAGE VIA HTTP AND WRITE IT WHERE AN UPLOADED FILE WOULD GO
             $uploadfile = PA::$upload_path . $uf_basename;
             if ($this->reg_user->download($avatar_url, $uploadfile)) {
                 $_POST['user_filename'] = $uf_basename;
                 $_POST['avatar_url'] = '';
             } else {
                 $this->reg_user->msg = "Could not retrieve file from URL:" . $avatar_url;
                 $this->reg_user->error = TRUE;
             }
         }
     }
 }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:33,代码来源:register.php

示例4: do_file_upload

function do_file_upload()
{
    $uploadfile = PA::$upload_path . basename($_FILES['network_image']['name']);
    $myUploadobj = new FileUploader();
    //creating instance of file.
    $image_type = 'image';
    $file = $myUploadobj->upload_file(PA::$upload_path, 'network_image', true, true, $image_type);
    if ($file == false) {
        $r = array('error' => TRUE, 'error_msg' => $myUploadobj->error);
    } else {
        $r = array('error' => FALSE, 'file' => $file);
    }
    return $r;
}
开发者ID:Cyberspace-Networks,项目名称:CoreSystem,代码行数:14,代码来源:cnnetwork.php

示例5: array

require_once "api/Tag/Tag.php";
require_once "web/includes/network.inc.php";
require_once "api/ModuleData/ModuleData.php";
include_once "web/languages/english/MessagesHandler.php";
$authorization_required = TRUE;
$error = FALSE;
$msg = NULL;
if (@$_POST['submit'] == 'Submit') {
    $data = array();
    //
    for ($i = 0; $i < count($_FILES); $i++) {
        if (!empty($_FILES['userfile_' . $i]['name'])) {
            $file_name = $_FILES['userfile_' . $i]['name'];
            $myUploadobj = new FileUploader();
            //creating instance of file.
            $file = $myUploadobj->upload_file(PA::$upload_path, 'userfile_' . $i, TRUE);
            if ($file == false) {
                $msg = $myUploadobj->error;
                $error = TRUE;
            } else {
                $error_file = FALSE;
                $msg = 'successfully updated';
            }
        }
        if ($_POST["userfile_url_{$i}"]) {
            $data[$i]['url'] = $_POST["userfile_url_{$i}"];
        }
        if ($_POST['caption'][$i]) {
            $data[$i]['title'] = $_POST['caption'][$i];
        }
        if (!empty($_FILES['userfile_' . $i]['name'])) {
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:31,代码来源:manage_emblem.php

示例6: array

     $skip_check = array('address');
 }
 $error_post = check_error($skip_check);
 //validation check
 if ($error_post['error'] == TRUE) {
     $error = TRUE;
     $error_msg = $error_post['error_msg'];
 }
 if (!$error_post) {
     //code to upload the icon image
     if (!empty($_FILES['inner_logo_image']['name'])) {
         $uploadfile = PA::$upload_path . basename($_FILES['inner_logo_image']['name']);
         $myUploadobj = new FileUploader();
         //creating instance of file.
         $image_type = 'image';
         $file = $new_inner_logo_image = $myUploadobj->upload_file(PA::$upload_path, 'inner_logo_image', true, true, $image_type);
         if ($file == false) {
             $error = TRUE;
             $error_msg = $file_upload_result['error_msg'];
             unset($data_icon_image);
         } else {
             $data_icon_image = array('inner_logo_image' => $file);
         }
     } else {
         unset($data_icon_image);
     }
     //...code to upload the icon image
     $network_basic_controls = $extra;
     $network_basic_controls['network_group_title'] = $_POST['network_group_title'];
     if (!empty($_POST['reciprocated_relationship'])) {
         $network_basic_controls['reciprocated_relationship'] = NET_YES;
开发者ID:Cyberspace-Networks,项目名称:CoreSystem,代码行数:31,代码来源:cnnetwork_configure.php

示例7: array

    array('caption'=>'Stretch to fit', 'value'=>DESKTOP_IMAGE_ACTION_STRETCH);
  $image_actions[1] = 
    array('caption'=>'Crop', 'value'=>DESKTOP_IMAGE_ACTION_CROP);
  $image_actions[2] = 
    array('caption'=>'Tile', 'value'=>DESKTOP_IMAGE_ACTION_TILE);
  $image_actions[3] = 
    array('caption'=>'Leave it alone', 'value'=>DESKTOP_IMAGE_ACTION_LEAVE);

  $profile = &$data_var['user_data_general'];

  if (!empty($_FILES['user_caption_image']['name'])) {
    $uploadfile = $uploaddir.basename($_FILES['user_caption_image']['name']);
    $myUploadobj = new FileUploader; //creating instance of file.
    $image_type = 'image';
    $file =
     $myUploadobj->upload_file($uploaddir,'user_caption_image',true,true,$image_type);
    if($file == false) {
       $msg = $myUploadobj->error;
       $error = TRUE;
    } else {
      $user_caption_image = $file;
    }
  } else {
    $user_caption_image = @$profile['user_caption_image'];
  }

if (@$_POST['profile_type'] == 'general') {

  $user = get_login_user();

  if (isset($_POST['submit'])) {
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:31,代码来源:desktop_image.php

示例8: create_new_network

function create_new_network($_form)
{
    // function checks initial settings for network creation
    $can_network_be_created = Network::can_network_be_created();
    if ($can_network_be_created['error'] == TRUE) {
        $config_error = TRUE;
        $error = TRUE;
        $error_msg = $can_network_be_created['error_msg'];
    } else {
        if (!PA::$login_uid) {
            $config_error = TRUE;
        }
    }
    //form_data is array used for form fields
    // its initialized by $_form
    $temp_data['action'] = 'add';
    $vartoset = array('address', 'name', 'tagline', 'category', 'desc', 'header_image', 'header_image_option', 'action', 'type', 'network_group_title', 'network_content_moderation');
    for ($i = 0; $i < count($vartoset); $i += 1) {
        $var = $vartoset[$i];
        if (!empty($_form[$var])) {
            $temp_data[$var] = trim($_form[$var]);
        }
        if ($var == 'type') {
            if (isset($_form[$var])) {
                $temp_data[$var] = $_form[$var];
            }
        }
    }
    if (empty($config_error)) {
        filter_all_post($_form);
        //filters all data of html
        $error_post = check_error();
        //validation check
        if ($error_post['error'] == TRUE) {
            $error = TRUE;
            $error_msg = $error_post['error_msg'];
        }
        if (!$error_post) {
            //upload file
            if (!empty($_FILES['network_image']['name'])) {
                $file_upload_result = do_file_upload();
                if ($file_upload_result['error']) {
                    $error = TRUE;
                    $error_msg = $file_upload_result['error_msg'];
                } else {
                    $header_image = $network_image = $file_upload_result['file'];
                }
            } else {
                //image hidden
                $header_image = $network_image = @$temp_data['header_image'];
            }
            //code to upload the icon image
            if (!empty($_FILES['inner_logo_image']['name'])) {
                $uploadfile = PA::$upload_path . basename($_FILES['inner_logo_image']['name']);
                $myUploadobj = new FileUploader();
                //creating instance of file.
                $image_type = 'image';
                $file = $myUploadobj->upload_file(PA::$upload_path, 'inner_logo_image', true, true, $image_type);
                if ($file == false) {
                    $error = TRUE;
                    $error_msg = $file_upload_result['error_msg'];
                    unset($data_icon_image);
                } else {
                    $data_icon_image = array('inner_logo_image' => $file);
                }
            } else {
                unset($data_icon_image);
            }
            //...code to upload the icon image
            $network_basic_controls = PA::$network_defaults;
            $network_basic_controls['basic']['header_image']['name'] = $header_image;
            $network_basic_controls['basic']['header_image']['option'] = @$_form['header_image_option'] ? $_form['header_image_option'] : DESKTOP_IMAGE_ACTION_STRETCH;
            // for title of network group
            $network_basic_controls['network_group_title'] = '';
            $network_basic_controls['network_group_title'] = $_form['network_group_title'];
            $network_basic_controls['network_content_moderation'] = @$_form['network_content_moderation'];
            $temp_data['address'] = strtolower($temp_data['address']);
            $data = array('user_id' => $_SESSION['user']['id'], 'name' => strip_tags($temp_data['name']), 'address' => $temp_data['address'], 'tagline' => strip_tags($temp_data['tagline']), 'category_id' => $temp_data['category'], 'type' => $temp_data['type'], 'description' => $temp_data['desc'], 'extra' => serialize($network_basic_controls), 'created' => time(), 'changed' => time());
            //add icon image
            if (!empty($data_icon_image['inner_logo_image'])) {
                $data = array_merge($data, $data_icon_image);
                $temp_data['inner_logo_image'] = $data_icon_image['inner_logo_image'];
            }
            $network = new Network();
            $network->set_params($data);
            try {
                $nid = $network->save();
                //default_page_setting($network->address); // populate page_default setting
            } catch (PAException $e) {
                $error = TRUE;
                $error_msg = "{$e->message}";
            }
            if (!empty($nid)) {
                $_extra = serialize(array('user' => true, 'network' => true, 'groups' => array()));
                Roles::set_user_role_for_network($network->user_id, ADMINISTRATOR_ROLE, $network->address, $_extra);
                $location = "http://" . $temp_data['address'] . '.' . PA::$domain_suffix . BASE_URL_REL . PA_ROUTE_CONFIGURE_NETWORK;
            }
        }
        $msg_array = array();
        $msg_array['failure_msg'] = @$error_msg;
//.........这里部分代码省略.........
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:101,代码来源:action.php

示例9: array

     $skip_check = array('address');
 }
 $error_post = check_error($skip_check);
 //validation check
 if ($error_post['error'] == TRUE) {
     $error = TRUE;
     $error_msg = $error_post['error_msg'];
 }
 if (!$error_post) {
     //code to upload the icon image
     if (!empty($_FILES['inner_logo_image']['name'])) {
         $uploadfile = $uploaddir . basename($_FILES['inner_logo_image']['name']);
         $myUploadobj = new FileUploader();
         //creating instance of file.
         $image_type = 'image';
         $file = $myUploadobj->upload_file($uploaddir, 'inner_logo_image', true, true, $image_type);
         if ($file == false) {
             $error = TRUE;
             $error_msg = $file_upload_result['error_msg'];
             unset($data_icon_image);
         } else {
             $data_icon_image = array('inner_logo_image' => $file);
         }
     } else {
         unset($data_icon_image);
     }
     //...code to upload the icon image
     $network_basic_controls = $extra;
     $network_basic_controls['network_group_title'] = $_POST['network_group_title'];
     if (!empty($_POST['reciprocated_relationship'])) {
         $network_basic_controls['reciprocated_relationship'] = NET_YES;
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:31,代码来源:network_statistics.php

示例10: PAException

     $image_type = 'image';
     $file = $myUploadobj->upload_file($uploaddir, 'groupphoto', true, true, $image_type);
     if ($file == false) {
         throw new PAException(GROUP_PARAMETER_ERROR, "File upload error: " . $myUploadobj->error);
     }
     $upfile = $file;
 }
 if (empty($_form['deafult_headerphoto'])) {
     if (empty($_FILES['headerphoto']['name'])) {
         $header_image = $_form['header_file'];
     } else {
         $uploadfile = $uploaddir . basename($_FILES['headerphoto']['name']);
         $myUploadobj = new FileUploader();
         //creating instance of file.
         $image_type = 'image';
         $file = $myUploadobj->upload_file($uploaddir, 'headerphoto', true, true, $image_type);
         if ($file == false) {
             throw new PAException(GROUP_PARAMETER_ERROR, "File upload error: " . $myUploadobj->error);
         }
         $header_image = $file;
     }
 } else {
     $header_image = null;
 }
 $result = Group::save_new_group($collection_id, $_SESSION['user']['id'], $groupname, $body, $upfile, $group_tags, $group_category, $access, $reg_type, $is_moderated, $header_image, $header_image_action, $display_header_image);
 $ccid = $result;
 if (!is_numeric($result)) {
     throw new PAException(GROUP_CREATION_FAILED, "Group creation failed: " . $result);
 } else {
     if (!$_REQUEST['gid']) {
         //auto email is sent, when a new group is created
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:31,代码来源:action.php

示例11: handleEdit

 private function handleEdit($request_data)
 {
     $this->err = '';
     $data = $this->filter($request_data);
     // handle photo upload
     if (!empty($_FILES)) {
         foreach ($_FILES as $field_name => $file_info) {
             if (!empty($file_info['name'])) {
                 $uploadfile = PA::$upload_path . basename($_FILES[$field_name]['name']);
                 $myUploadobj = new FileUploader();
                 $file = $myUploadobj->upload_file(PA::$upload_path, $field_name, true, true, 'image');
                 if ($file == false) {
                     $msg = $myUploadobj->error;
                     $this->err .= sprintf(__('Please upload a valid Game Image in %s'), ucfirst($field_name)) . "<br/>";
                     continue;
                 } else {
                     Storage::link($file, array("role" => "game_image", "user" => PA::$login_user->user_id));
                     $data[$field_name] = $file;
                 }
             } else {
                 if (!empty($this->entity->attributes[$field_name])) {
                     $data[$field_name] = $this->entity->attributes[$field_name];
                 }
             }
         }
     }
     if (empty($data['name'])) {
         $this->err .= __("Please supply a name.") . "<br/>";
     }
     if (empty($this->err)) {
         // sync it
         TypedGroupEntity::sync($data);
     }
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:34,代码来源:FamilyModule.php

示例12: image_uploaded

function image_uploaded()
{
    if (empty($_FILES['userfile']['name'])) {
        return false;
    } else {
        $uploadfile = PA::$upload_path . basename($_FILES['userfile']['name']);
        $myUploadobj = new FileUploader();
        // creating instance of file.
        $image_type = 'image';
        $file = $myUploadobj->upload_file(PA::$upload_path, 'userfile', true, true, $image_type);
        if ($file == false) {
            throw new CNException(INVALID_ID, "Error uploading image " . $myUploadobj->error);
        } else {
            Storage::link($file, array("role" => "event_banner", "user" => PA::$login_user->user_id));
            return $file;
        }
    }
}
开发者ID:Cyberspace-Networks,项目名称:CoreSystem,代码行数:18,代码来源:cnmodule_content.php

示例13: basename

/********/
$error = FALSE;
if (!$configure_permission) {
    $error = TRUE;
    $permission_denied_msg = "Sorry! you are not authorized to view content of this page";
}
if (@$_GET['msg_id']) {
    $error_msg = MessagesHandler::get_message($_GET['msg_id']);
}
if (@$_POST['submit'] == 'Submit') {
    if (!empty($_FILES['userfile_0']['name'])) {
        $file_name = $_FILES['userfile_0']['name'];
        $uploadfile = $uploaddir . basename($file_name);
        $myUploadobj = new FileUploader();
        //creating instance of file.
        $file = $myUploadobj->upload_file($uploaddir, 'userfile_0' . $i, TRUE);
        if ($file == false) {
            $msg = $myUploadobj->error;
            $error = TRUE;
        } else {
            $error_file = FALSE;
            $msg = 'successfully updated';
        }
    }
    $data = array();
    if ($_POST["userfile_url_0"]) {
        $data[0]['url'] = $_POST["userfile_url_0"];
    }
    if ($_POST['caption'][0]) {
        $data[0]['title'] = $_POST['caption'][0];
    }
开发者ID:CivicCommons,项目名称:oldBellCaPA,代码行数:31,代码来源:manage_taketour.php

示例14: handlePOST_addChild

 private function handlePOST_addChild($request_data)
 {
     global $error_msg;
     $error = FALSE;
     $login_name = trim($_POST['login_name']);
     $first_name = stripslashes(trim($_POST['first_name']));
     $last_name = stripslashes(trim($_POST['last_name']));
     $email = trim($_POST['email']);
     $password = trim($_POST['password']);
     $use_parent_email = $_POST['use_parent_email'];
     //echo "<pre>".print_r($_POST, 1)."</pre>"; die();
     if (!isset($_POST['state'])) {
         if (isset($_POST['stateOther'])) {
             $_POST['state'] = $_POST['stateOther'];
         }
     }
     if (isset($_POST['stateOther'])) {
         unset($_POST['stateOther']);
     }
     $msg = NULL;
     if (!Validation::validate_email($email) && !empty($_POST['email'])) {
         $email_invalid = TRUE;
         $error = TRUE;
         $msg .= '<br> Email address is not valid';
     }
     if (User::user_exist($login_name)) {
         $msg = "Username {$login_name} is already taken";
         $error = TRUE;
     }
     if ($error == FALSE) {
         $newuser = new User();
         $newuser->login_name = $login_name;
         $newuser->password = $password;
         $newuser->first_name = $first_name;
         $newuser->last_name = $last_name;
         $newuser->email = $email;
         $newuser->is_active = ACTIVE;
         if (!empty($_FILES['userfile']['name'])) {
             $myUploadobj = new FileUploader();
             //creating instance of file.
             $image_type = 'image';
             $file = $myUploadobj->upload_file(PA::$upload_path, 'userfile', true, true, $image_type);
             if ($file == false) {
                 $msg = $myUploadobj->error;
                 $error = TRUE;
             } else {
                 $newuser->picture = $file;
             }
         }
         if ($error == FALSE) {
             try {
                 if ($use_parent_email) {
                     $newuser->save($check_unique_email = false);
                 } else {
                     $newuser->save($check_unique_email = true);
                 }
                 if (!empty($file)) {
                     Storage::link($file, array("role" => "avatar", "user" => $newuser->user_id));
                 }
                 // creating message basic folders
                 Message::create_basic_folders($newuser->user_id);
                 // adding default relation
                 if ($newuser->user_id != SUPER_USER_ID) {
                     User_Registration::add_default_relation($newuser->user_id, PA::$network_info);
                 }
                 // adding default media as well as album
                 User_Registration::add_default_media($newuser->user_id, '', PA::$network_info);
                 User_Registration::add_default_media($newuser->user_id, '_audio', PA::$network_info);
                 User_Registration::add_default_media($newuser->user_id, '_video', PA::$network_info);
                 User_Registration::add_default_blog($newuser->user_id);
                 //adding default link categories & links
                 User_Registration::add_default_links($newuser->user_id);
                 // code for adding default desktop image for user
                 $desk_img = uihelper_add_default_desktopimage($newuser->user_id);
                 if (empty($desk_img)) {
                     $desktop_images = array('bay.jpg', 'everglade.jpg', 'bay_boat.jpg', 'delhi.jpg');
                     $rand_key = array_rand($desktop_images);
                     $desk_img = $desktop_images[$rand_key];
                 }
                 $states = array_values(PA::getStatesList());
                 $countries = array_values(PA::getCountryList());
                 $profile_keys = array('dob_day', 'dob_month', 'dob_year', 'homeAddress1', 'homeAddress2', 'city', 'state', 'country', 'postal_code', 'phone', 'use_parent_email');
                 $profile_data = array();
                 filter_all_post($_POST);
                 //filters all data of html
                 foreach ($profile_keys as $k => $pkey) {
                     if (!empty($_POST[$pkey])) {
                         if ($pkey == 'state' && $_POST[$pkey] >= 0) {
                             $prof_rec = array('uid' => $newuser->user_id, 'name' => $pkey, 'value' => $states[$_POST[$pkey]], 'type' => GENERAL, 'perm' => 1);
                         } else {
                             if ($pkey == 'country' && $_POST[$pkey] >= 0) {
                                 $prof_rec = array('uid' => $newuser->user_id, 'name' => $pkey, 'value' => $countries[$_POST[$pkey]], 'type' => GENERAL, 'perm' => 1);
                             } else {
                                 $prof_rec = array('uid' => $newuser->user_id, 'name' => $pkey, 'value' => $_POST[$pkey], 'type' => GENERAL, 'perm' => 1);
                             }
                         }
                         $profile_data[] = $prof_rec;
                     }
                 }
                 $profile_data[] = array('uid' => $newuser->user_id, 'name' => 'user_caption_image', 'value' => $desk_img, 'type' => GENERAL, 'perm' => 1);
//.........这里部分代码省略.........
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:101,代码来源:FamilyModerationModule.php

示例15: basicProfileSave

 /** !!
  ************************************************************************
  * The following methods take the request data, validate it, parse it,
  * and store it if there were no previous errors.
  ************************************************************************
  */
 public function basicProfileSave($request_data)
 {
     global $error_msg;
     $this->isError = TRUE;
     if (empty($request_data['first_name'])) {
         $this->message = __('Fields marked with * can not be empty, First name can not be empty.');
     } else {
         if (empty($request_data['email_address'])) {
             $this->message = __('Fields marked with * can not be empty, Email field is mandatory.');
         } else {
             if (!empty($request_data['pass']) || !empty($request_data['conpass'])) {
                 $set_new_password = true;
                 $new_password_ok = false;
                 if ($request_data['pass'] != $request_data['conpass']) {
                     $this->message = __('Password and confirm password should match.');
                 } else {
                     if (strlen($request_data['pass']) < PA::$password_min_length) {
                         $this->message = sprintf(__('Password should be of %s characters or more.'), PA::$password_min_length);
                     } else {
                         if (strlen($request_data['pass']) > PA::$password_max_length) {
                             $this->message = sprintf(__('Password should be less than %s charcaters.'), PA::$password_max_length);
                         } else {
                             // all is good
                             $new_password_ok = true;
                         }
                     }
                 }
             }
         }
     }
     if ($request_data['deletepicture'] == "true") {
         $this->handleDeleteUserPic($request_data);
     }
     if (empty($this->message) && !empty($_FILES['userfile']['name'])) {
         $uploadfile = PA::$upload_path . basename($_FILES['userfile']['name']);
         $myUploadobj = new FileUploader();
         $file = $myUploadobj->upload_file(PA::$upload_path, 'userfile', true, true, 'image');
         if ($file == false) {
             $this->message = $myUploadobj->error;
             $error = TRUE;
         } else {
             $this->user_info->picture = $file;
             Storage::link($file, array("role" => "avatar", "user" => $user->user_id));
         }
     }
     if (empty($this->message)) {
         //If there is no error message then try saving the user information.
         $this->user_info->first_name = $request_data['first_name'];
         $this->user_info->last_name = $request_data['last_name'];
         $this->user_info->email = $request_data['email_address'];
         if (!empty($request_data['pass'])) {
             $this->user_info->password = md5($request_data['pass']);
         }
         try {
             $this->user_info->save();
             $dynProf = new DynamicProfile(PA::$login_user);
             $dynProf->processPOST('basic');
             $dynProf->save('basic');
             $this->message = __('Profile updated successfully.');
             //        $this->redirect2 = PA_ROUTE_EDIT_PROFILE;
             //        $this->queryString = '?type='.$this->profile_type;
             $this->isError = FALSE;
         } catch (PAException $e) {
             $this->message = $e->message;
         }
     }
     $error_msg = $this->message;
 }
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:74,代码来源:EditProfileModule.php


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