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


PHP file_upload函数代码示例

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


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

示例1: doWebPost

 public function doWebPost()
 {
     global $_GPC, $_W;
     $id = intval($_GPC['id']);
     if (!empty($id)) {
         $item = pdo_fetch("SELECT * FROM " . tablename($this->headtable) . " WHERE id = :id", array(':id' => $id));
         if (empty($item)) {
             message('抱歉,楼盘不存在或是已经删除!', '', 'error');
         }
     }
     if (checksubmit('submit')) {
         if (empty($_GPC['title'])) {
             message('请输入商户名称!');
         }
         $data = array('weid' => $_W['weid'], 'title' => $_GPC['title'], 'buildingintro' => htmlspecialchars_decode($_GPC['buildingintro']), 'traffic' => $_GPC['traffic'], 'projectintro' => $_GPC['projectintro'], 'phone' => $_GPC['phone'], 'province' => $_GPC['resideprovince'], 'city' => $_GPC['residecity'], 'dist' => $_GPC['residedist'], 'address' => $_GPC['address'], 'lng' => $_GPC['lng'], 'lat' => $_GPC['lat'], 'createtime' => TIMESTAMP);
         if (!empty($_FILES['thumb']['tmp_name'])) {
             file_delete($_GPC['thumb_old']);
             $upload = file_upload($_FILES['thumb']);
             if (is_error($upload)) {
                 message($upload['message'], '', 'error');
             }
             $data['thumb'] = $upload['path'];
         }
         if (empty($id)) {
             pdo_insert($this->headtable, $data);
         } else {
             unset($data['createtime']);
             pdo_update($this->headtable, $data, array('id' => $id));
         }
         message('商户信息更新成功!', create_url('site/module/display', array('name' => 'lxybuilding')), 'success');
     }
     include $this->template('post');
 }
开发者ID:alextiannus,项目名称:wormwood_wechat,代码行数:33,代码来源:site.php

示例2: doWebAddshop

 public function doWebAddshop()
 {
     global $_GPC, $_W;
     $rid = intval($_GPC['rid']);
     $id = intval($_GPC['id']);
     if (!empty($id)) {
         $item = pdo_fetch("SELECT * FROM " . tablename('hotel_shop') . " WHERE id = :id", array(':id' => $id));
         if (empty($item)) {
             message('抱歉,房型不存在或是已经删除!', '', 'error');
         }
     }
     if (checksubmit('submit')) {
         if (empty($_GPC['style'])) {
             message('请输入房型!');
         }
         $data = array('weid' => $_W['weid'], 'rid' => $rid, 'style' => $_GPC['style'], 'oprice' => $_GPC['oprice'], 'cprice' => $_GPC['cprice'], 'thumb' => $_GPC['thumb'], 'device' => htmlspecialchars_decode($_GPC['device']));
         if (!empty($_FILES['thumb']['tmp_name'])) {
             file_delete($_GPC['thumb_old']);
             $upload = file_upload($_FILES['thumb']);
             if (is_error($upload)) {
                 message($upload['message'], '', 'error');
             }
             $data['thumb'] = $upload['path'];
         }
         if (empty($id)) {
             pdo_insert('hotel_shop', $data);
         } else {
             pdo_update('hotel_shop', $data, array('id' => $id));
         }
         message('房型信息更新成功!', $this->createWebUrl('shop', array('id' => $_GPC['rid'])), 'success');
     }
     include $this->template('addshop');
 }
开发者ID:alextiannus,项目名称:wormwood_wechat,代码行数:33,代码来源:site.php

示例3: fieldsFormSubmit

 public function fieldsFormSubmit($rid = 0)
 {
     global $_GPC, $_W;
     $id = intval($_GPC['reply_id']);
     $credit = intval($_GPC['credit']);
     $insert = array('rid' => $rid, 'start_time' => strtotime($_GPC['start_time']), 'end_time' => strtotime($_GPC['end_time']), 'awardrules' => $_GPC['awardrules'], 'awardinfo' => $_GPC['awardinfo'], 'days' => $_GPC['days'], 'credit' => $credit);
     if (!empty($_FILES['thumb']['tmp_name'])) {
         file_delete($_GPC['thumb_old']);
         $upload = file_upload($_FILES['thumb']);
         if (is_error($upload)) {
             message($upload['message'], '', 'error');
         }
         $insert['thumb'] = $upload['path'];
     } else {
         $tmp_file = array(name => "registration_top.jpg", tmp_name => "{$_SERVER['DOCUMENT_ROOT']}/source/modules/cgtsignin/template/style/images/registration_top.jpg");
         $upload = file_upload($tmp_file);
         if (is_error($upload)) {
             message($upload['message'], '', 'error');
         }
         $insert['thumb'] = $upload['path'];
     }
     if (empty($id)) {
         pdo_insert($this->tablename, $insert);
     } else {
         pdo_update($this->tablename, $insert, array('id' => $id));
     }
 }
开发者ID:alextiannus,项目名称:wormwood_wechat,代码行数:27,代码来源:module.php

示例4: update_confirm

 public function update_confirm($id)
 {
     $this->Video_model->update_video($id);
     $data = $this->Video_model->get_record_by_id($id);
     if (isset($_FILES["videoInput"])) {
         unlink('./uploads/' . $data[0]['file_name']);
         $status = file_upload();
         if ($status[0] == 0) {
             $responsePattern = $this->Video_model->update_video_attachement($id, $status[1][0], $status[1][1], $status[1][2]);
             if ($responsePattern[0] == '0') {
                 echo json_encode(array('0', "更新成功"));
                 $this->Video_model->update_video($id);
                 $data = $this->Video_model->get_record_by_id($id);
             } else {
                 echo json_encode(array('1', $responsePattern[1]));
                 return;
             }
         } else {
             echo json_encode(array('1', $responsePattern[1]));
             return;
         }
     } else {
         echo json_encode(array('0', "更新成功"));
         $this->Video_model->update_video($id);
         $data = $this->Video_model->get_record_by_id($id);
     }
 }
开发者ID:khjay,项目名称:Automatic-scheduling-video,代码行数:27,代码来源:Video.php

示例5: user_update

function user_update()
{
    $user = new User();
    if ($val = get('firstname')) {
        $user->firstname = $val;
    }
    if ($val = get('lastname')) {
        $user->lastname = $val;
    }
    if ($val = get('pseudonym')) {
        $user->username = $val;
    }
    if ($val = get('age')) {
        $user->age = $val;
    }
    if ($val = get('gender')) {
        $user->gender = $val;
    }
    if ($val = get('location_id')) {
        $user->location = new Location($val);
    }
    $files = file_upload($_FILES);
    if (!empty($files)) {
        $user->picture = $files[0];
    }
    $email = get('email');
    $p = get('password');
    $cp = get('cpassword');
    if ($email && $p && $cp && $p == $cp) {
        $user->email = $email;
        $user->password = md5($email . $password);
    }
    $user->save();
    redirect('/user/');
}
开发者ID:nodefortytwo,项目名称:areyouhappy,代码行数:35,代码来源:user.php

示例6: edit

 public function edit($id, $request)
 {
     $fill_array = ['title' => $request->title, 'permalink' => $request->permalink, 'body' => $request->body, 'is_published' => $request->is_published];
     if ($uploaded_file = file_upload('featured_image', static::$image_upload_directory, static::$image_allowed_extension)) {
         $fill_array['featured_image'] = $uploaded_file;
     }
     return $this->update($fill_array, $id);
 }
开发者ID:NablusTechMeetups,项目名称:web,代码行数:8,代码来源:BlogRepositoryEloquent.php

示例7: edit

 public function edit($id, $request)
 {
     $fill_array = ['first_name' => $request->first_name, 'last_name' => $request->last_name, 'location' => $request->location, 'arabic_full_name' => $request->arabic_full_name, 'profession' => $request->profession, 'profession_location' => $request->profession_location, 'phone_number' => $request->phone_number, 'gender' => $request->gender, 'profession' => $request->profession, 'bio' => $request->bio];
     if ($uploaded_file = file_upload('image', static::$image_upload_directory, static::$image_allowed_extension)) {
         $fill_array['image'] = $uploaded_file;
     }
     return $this->update($fill_array, $id);
 }
开发者ID:NablusTechMeetups,项目名称:web,代码行数:8,代码来源:UserRepositoryEloquent.php

示例8: edit

 public function edit($id, $request)
 {
     $fill_array = ['title' => $request->title, 'body' => $request->body, 'permalink' => $request->permalink, 'is_registration_open' => $request->is_registration_open, 'max_registrars_count' => $request->max_registrars_count, 'location' => $request->location, 'date' => $request->date, 'require_additional_fields' => $request->max_registrars_count, 'is_published' => $request->is_published, 'survey_id' => $request->survey_id, 'type' => $request->type];
     if ($uploaded_file = file_upload('featured_image', static::$image_upload_directory, static::$image_allowed_extension)) {
         $fill_array['featured_image'] = $uploaded_file;
     }
     return $this->update($fill_array, $id);
 }
开发者ID:NablusTechMeetups,项目名称:web,代码行数:8,代码来源:EventRepositoryEloquent.php

示例9: upload

function upload($about, $exts, $critical = 0, $dir = "", $neoname = "")
{
    $options = new FileUploadOptions();
    $options->key = $about;
    $options->extensions = $exts;
    $options->is_critical = (bool) $critical;
    $options->dir = $dir;
    $options->neoname = $neoname;
    return file_upload($options);
}
开发者ID:Bodigrim,项目名称:durmstrang,代码行数:10,代码来源:file-upload.php

示例10: proc_upfiles

 /**
  * 处理上传文件
  * @return unknown_type
  */
 function proc_upfiles()
 {
     import_func('file');
     if (!empty($_FILES)) {
         foreach ($_FILES as $k => $f) {
             if (!empty($_FILES[$k]['type'])) {
                 $_POST[$k] = file_upload($k);
             }
         }
     }
 }
开发者ID:jinguanio,项目名称:swoole_websocket,代码行数:15,代码来源:GeneralView.php

示例11: fans_update

/**
 * [WDL] Copyright (c) 2013 B2CTUI.COM
 * $sn: origins/source/model/fans.mod.php : v 866195d935cc : 2014/05/16 09:42:08 : veryinf $
 */
function fans_update($user, $fields)
{
    global $_W;
    $_W['weid'] && ($fields['weid'] = $_W['weid']);
    $struct = cache_load('fansfields');
    if (empty($fields)) {
        return false;
    }
    if (empty($struct)) {
        $struct = cache_build_fans_struct();
    }
    foreach ($fields as $field => $value) {
        if (!in_array($field, $struct)) {
            unset($fields[$field]);
        }
    }
    if (empty($fields['avatar']) && !empty($_FILES['avatar']['tmp_name'])) {
        $_W['uploadsetting'] = array();
        $_W['uploadsetting']['avatar']['folder'] = 'avatar';
        $_W['uploadsetting']['avatar']['extentions'] = $_W['config']['upload']['image']['extentions'];
        $_W['uploadsetting']['avatar']['limit'] = $_W['config']['upload']['image']['limit'];
        $upload = file_upload($_FILES['avatar'], 'avatar', $user);
        if (is_error($upload)) {
            message($upload['message']);
        }
        $fields['avatar'] = $upload['path'];
    } elseif (!empty($fields['avatar'])) {
        $pathinfo = pathinfo($fields['avatar']);
        $fields['avatar'] = $pathinfo['basename'];
    }
    $isexists = pdo_fetchcolumn("SELECT id FROM " . tablename('fans') . " WHERE from_user = :user", array(':user' => $user));
    if (empty($isexists)) {
        $fields['from_user'] = $user;
        $fields['createtime'] = TIMESTAMP;
        foreach ($struct as $field) {
            if ($field != 'id' && $field != 'follow' && !isset($fields[$field])) {
                $fields[$field] = '';
            }
        }
        if (empty($fields['salt'])) {
            $fields['salt'] = random(8);
        }
        return pdo_insert('fans', $fields);
    } else {
        unset($fields['from_user']);
        return pdo_update('fans', $fields, array('from_user' => $user));
    }
}
开发者ID:keycoolkui,项目名称:weixinfenxiao,代码行数:52,代码来源:fans.mod.php

示例12: doWebDisplay

 public function doWebDisplay()
 {
     global $_GPC, $_W;
     $op = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
     $id = intval($_GPC['id']);
     if ($op == 'post') {
         if (!empty($id)) {
             $sql = "select * from" . tablename('chax') . "where weid='{$_W['weid']}' and id=" . $id;
             $item = pdo_fetch($sql);
         }
         $data = array('weid' => $_W['weid'], 'title' => $_GPC['title'], 'url' => $_GPC['url'], 'displayorder' => intval($_GPC['displayorder']), 'status' => intval($_GPC['status']));
         if ($_W['ispost']) {
             if (!empty($_FILES['fileicon']['tmp_name'])) {
                 file_delete($_GPC['topPicture-old']);
                 $upload = file_upload($_FILES['fileicon']);
                 if (is_error($upload)) {
                     message($upload['message'], '', 'error');
                 }
                 $data['fileicon'] = $upload['path'];
             }
             if (empty($id)) {
                 pdo_insert('chax', $data);
             } else {
                 pdo_update('chax', $data, array('id' => $id));
             }
             message('更新成功', referer(), 'success');
         }
     } elseif ($op == 'display') {
         $sql = "select * from " . tablename('chax') . "where weid='{$_W['weid']}'";
         $row = pdo_fetchall($sql);
     } elseif ($op == 'delete') {
         pdo_delete('chax', array('id' => $id, 'weid' => $_W['weid']));
         message('删除成功', referer(), 'success');
     } elseif ($op == 'edit') {
         $status = intval($_GPC['status']);
         if ($status == 1) {
             $sql = "update" . tablename('chax') . " set status = 0 where weid= '{$_W['weid']}' and id=" . $id;
             pdo_query($sql);
         } else {
             $sql = "update" . tablename('chax') . " set status = 1 where weid= '{$_W['weid']}' and id=" . $id;
             pdo_query($sql);
         }
         message('更新成功', referer(), 'success');
     }
     include $this->template('display');
 }
开发者ID:alextiannus,项目名称:wormwood_wechat,代码行数:46,代码来源:site.php

示例13: fileUpload

 private function fileUpload($file, $type)
 {
     global $_W;
     set_time_limit(0);
     $_W['uploadsetting'] = array();
     $_W['uploadsetting']['music']['folder'] = 'music/' . $_W['weid'];
     $_W['uploadsetting']['music']['extentions'] = array('mp3', 'wma', 'wav', 'amr');
     $_W['uploadsetting']['music']['limit'] = 50000;
     $result = array();
     $upload = file_upload($file, 'music');
     if (is_error($upload)) {
         message($upload['message'], '', 'ajax');
     }
     $result['url'] = $_W['config']['upload']['attachdir'] . $upload['path'];
     $result['error'] = 0;
     $result['filename'] = $upload['path'];
     return $result;
 }
开发者ID:alextiannus,项目名称:wormwood_wechat,代码行数:18,代码来源:module.php

示例14: uploadFile

 function uploadFile($file = null)
 {
     global $is_API;
     if (is_null($file)) {
         $file = $_FILES;
     }
     $result = array('result' => 0, 'link' => '');
     if ($file['file']['name']) {
         $upfile = file_upload($file['file']['tmp_name'], "board_" . $_POST['id'] . "_" . $file['file']['name'], ".." . UPLOAD_PATH . "/" . date("Y") . "/" . date("m") . "/", 1);
         if ($upfile) {
             $result['result'] = 1;
             $result['link'] = UPLOAD_PATH . "/" . date("Y") . "/" . date("m") . "/" . $upfile;
         }
         //thumbnail($path."/".$upfile, $path."/thumb_".$upfile, 120, 100, 1);
     }
     if ($is_API) {
         echo json_encode($result);
     } else {
         return $upfile;
     }
 }
开发者ID:guruahn,项目名称:gjboard,代码行数:21,代码来源:postscontroller.php

示例15: saver_file

/**
 * File saver
 *
 * @param array $attr
 * @param array $item
 *
 * @return bool
 */
function saver_file(array $attr, array &$item) : bool
{
    $item[$attr['id']] = null;
    $file = http_files('data')[$item['_id']][$attr['id']] ?? null;
    // Delete old file
    if (!empty($item['_old'][$attr['id']]) && ($file || !empty($item['_delete'][$attr['id']])) && !media_delete($item['_old'][$attr['id']])) {
        $item['_error'][$attr['id']] = _('Could not delete old file %s', $item['_old'][$attr['id']]);
        return false;
    }
    // No upload
    if (!$file) {
        return true;
    }
    $value = generator_file($file['name'], project_path('media'));
    // Upload failed
    if (!file_upload($file['tmp_name'], project_path('media', $value))) {
        $item['_error'][$attr['id']] = _('File upload failed');
        return false;
    }
    $item[$attr['id']] = $value;
    return true;
}
开发者ID:akilli,项目名称:qnd,代码行数:30,代码来源:saver.php


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