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


PHP uploadFile函数代码示例

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


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

示例1: insertArticleIntoDB

function insertArticleIntoDB()
{
    // Create DB connection
    require_once __ROOT__ . '/admin/include/DBclass.php';
    $sqlConn = new DBclass("nazmarket");
    // Extract received informations.
    // Do checks for SQL injection, data times and other limitations.
    $articlename = $sqlConn->realEscapeString(filter_input(INPUT_POST, 'articlename', FILTER_DEFAULT));
    $idcategory = $sqlConn->realEscapeString(filter_input(INPUT_POST, 'idcategory', FILTER_DEFAULT));
    $idcompany = $sqlConn->realEscapeString(filter_input(INPUT_POST, 'idcompany', FILTER_DEFAULT));
    $idunit = $sqlConn->realEscapeString(filter_input(INPUT_POST, 'idunit', FILTER_DEFAULT));
    $articlecomment = $sqlConn->realEscapeString(filter_input(INPUT_POST, 'articlecomment', FILTER_DEFAULT));
    $price = $sqlConn->realEscapeString(filter_input(INPUT_POST, 'price', FILTER_DEFAULT));
    $available = $sqlConn->realEscapeString(filter_input(INPUT_POST, 'available', FILTER_DEFAULT));
    // Corresponds to the name in HTML.
    $articleimage = uploadFile("articleimage");
    if ($articleimage == -1) {
        $articleimage = "";
    }
    // $articleName =
    //[articlename] => [idcategory] => 1 [idcompany] => 1 [articlecomment] => e.g. 500 [idunit] => 1 [price]
    // Insert:
    $query = "INSERT INTO article (articlename, idcategory, idcompany, idunit,\r\n            price, articlecomment, articleimage, available) \r\n            VALUES ('" . $articlename . "','" . $idcategory . "','" . $idcompany . "'," . $idunit . "," . $price . ",'" . $articlecomment . "','" . $articleimage . "'," . $available . ")";
    echo "<br/>" . $query . "<br/>";
    $sqlConn->exeQuery($query);
    // Remove DB connection
    unset($sqlConn);
}
开发者ID:skoja,项目名称:NazMarket,代码行数:28,代码来源:editarticleform.php

示例2: uploadFile

function uploadFile($copy_src_filename, $originalfilename, $testnewfilename)
{
    global $i;
    $dir_upload = '../upload/';
    if (!is_writable($dir_upload)) {
        @chmod($dir_upload, 0755);
    }
    if (file_exists($dir_upload . $testnewfilename)) {
        $fileinfo = pathinfo($originalfilename);
        $filename_noext = basename($originalfilename, '.' . $fileinfo['extension']);
        $i++;
        $suffix = str_pad($i, 3, '0', STR_PAD_LEFT);
        $newfilename = $filename_noext . ' - ' . $suffix . '.' . $fileinfo['extension'];
        uploadFile($copy_src_filename, $originalfilename, $newfilename);
    } else {
        $_SESSION['uploaded_files'][] = $testnewfilename;
        copy($copy_src_filename, $dir_upload . $testnewfilename);
        // image file name needed to append the image with its new name in uploadSuccess (handlers.js)
        ?>
		{"filename":"<?php 
        echo $testnewfilename;
        ?>
"}
	<?php 
    }
}
开发者ID:sistorm,项目名称:ventdecheznous,代码行数:26,代码来源:upload.php

示例3: uploadPackage

/**
* @param string The class name for the installer
* @param string The URL option
* @param string The element name
*/
function uploadPackage($installerClass, $option, $element, $client)
{
    global $mainframe, $adminLanguage;
    $installer = new $installerClass();
    // Check if file uploads are enabled
    if (!(bool) ini_get('file_uploads')) {
        HTML_installer::showInstallMessage($adminLanguage->A_INSTALL_ENABLE_MSG, $adminLanguage->A_INSTALL_ERROR_MSG_TITLE, $installer->returnTo($option, $element, $client));
        exit;
    }
    // Check that the zlib is available
    if (!extension_loaded('zlib')) {
        HTML_installer::showInstallMessage($adminLanguage->A_INSTALL_ZLIB_MSG, $adminLanguage->A_INSTALL_ERROR_MSG_TITLE, $installer->returnTo($option, $element, $client));
        exit;
    }
    $userfile = mosGetParam($_FILES, 'userfile', null);
    if (!$userfile) {
        HTML_installer::showInstallMessage($adminLanguage->A_INSTALL_NOFILE_MSG, $adminLanguage->A_INSTALL_NEWMODULE_ERROR_MSG_TITLE, $installer->returnTo($option, $element, $client));
        exit;
    }
    $userfile_name = $userfile['name'];
    $msg = '';
    $resultdir = uploadFile($userfile['tmp_name'], $userfile['name'], $msg);
    if ($resultdir !== false) {
        if (!$installer->upload($userfile['name'])) {
            HTML_installer::showInstallMessage($installer->getError(), $adminLanguage->A_INSTALL_UPLOAD_PRE . $element . $adminLanguage->A_INSTALL_UPLOAD_POST, $installer->returnTo($option, $element, $client));
        }
        $ret = $installer->install();
        HTML_installer::showInstallMessage($installer->getError(), $adminLanguage->A_INSTALL_UPLOAD_PRE . $element . ' - ' . ($ret ? $adminLanguage->A_INSTALL_SUCCESS : $adminLanguage->A_INSTALL_FAILED), $installer->returnTo($option, $element, $client));
        cleanupInstall($userfile['name'], $installer->unpackDir());
    } else {
        HTML_installer::showInstallMessage($msg, $adminLanguage->A_INSTALL_UPLOAD_PRE . $element . $adminLanguage->A_INSTALL_UPLOAD_POST2, $installer->returnTo($option, $element, $client));
    }
}
开发者ID:cwcw,项目名称:cms,代码行数:38,代码来源:admin.installer.php

示例4: updateCategory

 function updateCategory()
 {
     global $CONFIG;
     $id = _p('category_id');
     $parent = _p('parent');
     $name = _p('name');
     $description = _p('description');
     $meta_description = _p('meta_description');
     $meta_keywords = _p('meta_keywords');
     $top = _p('top');
     $column = _p('column');
     $sort_order = _p('sort_order');
     $status = _p('status');
     $pathUpload = "";
     $date_modified = date('Y-m-d H:i:s');
     if ($_FILES['gambar']['name'] == "") {
         $query = "UPDATE ck_category SET parent_id={$parent}, top={$top}, `column`={$column}, sort_order={$sort_order}, status={$status}, date_modified = '{$date_modified}' WHERE category_id = {$id}";
     } else {
         $image = uploadFile('gambar', $pathUpload, 'image');
         $query = "UPDATE ck_category SET image='{$image}', parent_id={$parent}, top={$top}, `column`={$column}, sort_order={$sort_order}, status={$status}, date_modified='{$date_modified}' WHERE category_id = {$id}";
     }
     $query_desc = "UPDATE ck_category_description SET name = '{$name}', description = '{$description}', meta_description = '{$meta_description}', meta_keyword = '{$meta_keywords}' WHERE category_id = {$id}";
     $result_query = $this->query($query);
     $result_desc = $this->query($query_desc);
     // pr ($_FILES['gambar']);
     // echo ("<br/>");
     // pr ($image);
     // echo ("<br/>");
     // echo "<br />".$query;
     // exit();
     return $result_desc && $result_query;
 }
开发者ID:TrinataBhayanaka,项目名称:codekir-cms,代码行数:32,代码来源:categoryHelper.php

示例5: addProduct

 function addProduct()
 {
     $category = _p('category');
     $name = _p('name');
     $description = _p('description');
     $meta_desc = _p('meta_descriptoion');
     $meta_key = _p('meta_keywords');
     $model = _p('model');
     $sku = _p('sku');
     $upc = _p('upc');
     $ean = _p('ean');
     $jan = _p('jan');
     $isbn = _p('isbn');
     $mpn = _p('mpn');
     $weight = _p('weight');
     $weight_class = _p('weight_class');
     $length = _p('length');
     $width = _p('width');
     $height = _p('height');
     $length_class = _p('length_class');
     $location = _p('location');
     $price = _p('price');
     $quantity = _p('quantity');
     $minimum = _p('minimum');
     $substract = _p('substract');
     $shipping = _p('shipping');
     $status = _p('status');
     $date_added = date('Y-m-d H:i:s');
     $pathUpload = "";
     $image = uploadFile('gambar', $pathUpload, 'image');
     $query_product = "INSERT INTO ck_product (`model`, `sku`, `upc`, `ean`, `jan`, `isbn`, `mpn`, `location`, `quantity`, `image`, `shipping`, `price`, `weight`, `weight_class_id`, `length`, `width`, `height`, `length_class_id`, `subtract`, `minimum`, `sort_order`, `status`, `date_added`) VALUES ('{$model}', '{$sku}', '{$upc}', '{$ean}', '{$jan}', '{$isbn}', '{$mpn}', '{$location}', {$quantity}, '{$image}', '{$shipping}', {$price}, {$weight}, '{$weight_class}', {$length}, {$width}, {$height}, '{$length_class}', '{$substract}', {$minimum}, '', {$status}, '{$date_added}' )";
     echo "<br />" . $query_product;
     echo "<br />";
     pr($image);
 }
开发者ID:TrinataBhayanaka,项目名称:codekir-cms,代码行数:35,代码来源:productHelper.php

示例6: __construct

 public function __construct()
 {
     $title = getInput("title");
     $description = getInput("description");
     // Create filestore object to store file information
     $file = new File();
     $file->title = $title;
     $file->description = $description;
     $file->owner_guid = getLoggedInUserGuid();
     $file->access_id = "public";
     $file->container_guid = getInput("container_guid");
     $guid = $file->save();
     uploadFile("file", $guid, getLoggedInUserGuid());
     $file = getEntity($guid);
     Image::createThumbnail($file->guid, TINY);
     Image::createThumbnail($file->guid, SMALL);
     Image::createThumbnail($file->guid, MEDIUM);
     Image::createThumbnail($file->guid, LARGE);
     Image::createThumbnail($file->guid, EXTRALARGE);
     Image::createThumbnail($file->guid, HUGE);
     new Activity(getLoggedInUserGuid(), "action:upload:file", $guid);
     runHook("upload_file:redirect");
     new SystemMessage("Your file has been uploaded.");
     forward();
 }
开发者ID:socialapparatus,项目名称:socialapparatus,代码行数:25,代码来源:FileUploadActionHandler.php

示例7: uploadPackage

/**
* @param string The class name for the installer
* @param string The URL option
* @param string The element name
*/
function uploadPackage($installerClass, $option, $element, $client)
{
    josSpoofCheck();
    $installer = new $installerClass();
    // Check if file uploads are enabled
    if (!(bool) ini_get('file_uploads')) {
        HTML_installer::showInstallMessage("O instalador não pode continuar antes que o envio dos arquivos esteja concluido. Por favor, use a instalação a partir do diretório.", 'Installer - Error', $installer->returnTo($option, $element, $client));
        exit;
    }
    // Check that the zlib is available
    if (!extension_loaded('zlib')) {
        HTML_installer::showInstallMessage("O instalador não pode continuar antes que o zlib esteja habilitado", 'Installer - Error', $installer->returnTo($option, $element, $client));
        exit;
    }
    $userfile = mosGetParam($_FILES, 'userfile', null);
    if (!$userfile) {
        HTML_installer::showInstallMessage('Nenhum arquivo selecionado', 'envio novo módulo - erro', $installer->returnTo($option, $element, $client));
        exit;
    }
    $userfile_name = $userfile['name'];
    $msg = '';
    $resultdir = uploadFile($userfile['tmp_name'], $userfile['name'], $msg);
    if ($resultdir !== false) {
        if (!$installer->upload($userfile['name'])) {
            HTML_installer::showInstallMessage($installer->getError(), 'Envio ' . $element . ' - Envio Falhou', $installer->returnTo($option, $element, $client));
        }
        $ret = $installer->install();
        HTML_installer::showInstallMessage($installer->getError(), 'Envio ' . $element . ' - ' . ($ret ? 'Sucesso' : 'Falhou'), $installer->returnTo($option, $element, $client));
        cleanupInstall($userfile['name'], $installer->unpackDir());
    } else {
        HTML_installer::showInstallMessage($msg, 'Envio ' . $element . ' -  Envio Falhou', $installer->returnTo($option, $element, $client));
    }
}
开发者ID:patricmutwiri,项目名称:joomlaclube,代码行数:38,代码来源:admin.installer.php

示例8: uploadPackage

/**
* @param string The class name for the installer
* @param string The URL option
* @param string The element name
*/
function uploadPackage($installerClass, $option, $element, $client)
{
    josSpoofCheck();
    $installer = new $installerClass();
    // Check if file uploads are enabled
    if (!(bool) ini_get('file_uploads')) {
        HTML_installer::showInstallMessage("The installer can't continue before file uploads are enabled. Please use the install from directory method.", 'Installer - Error', $installer->returnTo($option, $element, $client));
        exit;
    }
    // Check that the zlib is available
    if (!extension_loaded('zlib')) {
        HTML_installer::showInstallMessage("The installer can't continue before zlib is installed", 'Installer - Error', $installer->returnTo($option, $element, $client));
        exit;
    }
    $userfile = mosGetParam($_FILES, 'userfile', null);
    if (!$userfile) {
        HTML_installer::showInstallMessage('No file selected', 'Upload new module - error', $installer->returnTo($option, $element, $client));
        exit;
    }
    $userfile_name = $userfile['name'];
    $msg = '';
    $resultdir = uploadFile($userfile['tmp_name'], $userfile['name'], $msg);
    if ($resultdir !== false) {
        if (!$installer->upload($userfile['name'])) {
            HTML_installer::showInstallMessage($installer->getError(), 'Upload ' . $element . ' - Upload Failed', $installer->returnTo($option, $element, $client));
        }
        $ret = $installer->install();
        HTML_installer::showInstallMessage($installer->getError(), 'Upload ' . $element . ' - ' . ($ret ? 'Success' : 'Failed'), $installer->returnTo($option, $element, $client));
        cleanupInstall($userfile['name'], $installer->unpackDir());
    } else {
        HTML_installer::showInstallMessage($msg, 'Upload ' . $element . ' -  Upload Error', $installer->returnTo($option, $element, $client));
    }
}
开发者ID:jwest00724,项目名称:Joomla-1.0,代码行数:38,代码来源:admin.installer.php

示例9: editUser

/**
 *编辑商品
 * @param int $id
 * @return string
 */
function editUser($id)
{
    $arr = $_POST;
    $path = "../uploads";
    $uploadFiles = uploadFile($path);
    $where = "id={$id}";
    $totalCap = getCityCapById(getcIdById($id)) - getCapById($id) + $arr['capacity'];
    //减去旧的,加上新的
    $sql = "update biogas_city set totalCap=" . $totalCap . " where id=" . getcIdById($id);
    mysql_query($sql);
    //更新城市的总池容
    $res = update("biogas_user", $arr, $where);
    $uid = $id;
    if ($res && $uid) {
        if ($uploadFiles && is_array($uploadFiles)) {
            foreach ($uploadFiles as $uploadFile) {
                $arr1['uid'] = $uid;
                $arr1['albumPath'] = $uploadFile['name'];
                addAlbum($arr1);
            }
        }
        $mes = "<p>编辑成功!</p><a href='listUser.php' target='mainFrame'>查看用户列表</a>";
    } else {
        $mes = "<p>编辑失败!</p><a href='listUser.php' target='mainFrame'>重新编辑</a>";
    }
    return $mes;
}
开发者ID:BigeyeDestroyer,项目名称:biogas,代码行数:32,代码来源:user.inc.php

示例10: __construct

 function __construct()
 {
     adminGateKeeper();
     $guid = getInput("guid");
     $title = getInput("title");
     $description = getInput('description');
     $price = getInput("price");
     $hidden = getInput("hidden") == 0 ? false : true;
     $product = getEntity($guid);
     $product->title = $title;
     $product->description = $description;
     $product->price = $price;
     $product->hidden = $hidden;
     $product->save();
     $product->createAvatar();
     if (isset($_FILES["download"]) && $_FILES["download"]["name"]) {
         $file = new File();
         $file->access_id = "product";
         $file->container_guid = $product->guid;
         $guid = $file->save();
         uploadFile("download", $guid, array("zip"));
         $product->download = $guid;
     }
     new SystemMessage("Your product has been updated.");
     forward("store");
 }
开发者ID:socialapparatus,项目名称:socialapparatus,代码行数:26,代码来源:EditProductActionHandler.php

示例11: insertSubmission

 /**
  * @noAuth
  * @url POST /?submissions
  * @url PUT /?submissions/$id
  */
 function insertSubmission($id = null, $data)
 {
     if ($data == null) {
         $data = $_POST;
     } else {
         $data = get_object_vars($data);
     }
     //var_dump($data);
     //check if file submitted
     $file = false;
     if (isset($_FILES['file']) && !empty($_FILES['file']['name']) && $_FILES['file']['size'] > 0) {
         $file = $_FILES['file'];
         $data['image_result'] = $file['name'];
     }
     //validate
     $validationRules = array();
     if (isset($data['text_question']) && !empty($data['text_question'])) {
         $validationRules['text_result'] = VALIDATE_RULE_NON_EMPTY_STRING | VALIDATE_RULE_REQUIRED;
     }
     if (isset($data['image_question']) && !empty($data['image_question'])) {
         $validationRules['image_result'] = VALIDATE_RULE_NON_EMPTY_STRING | VALIDATE_RULE_REQUIRED;
     }
     $validator = new Validator($data);
     $errors = $validator->validate($validationRules);
     if (!empty($errors)) {
         throw new RestException(400, implode(" ", $errors));
     }
     //add new entry
     if ($id == null) {
         //insert into database
         $db = new SubmissionDatabase();
         $db->insertSubmission($data);
         $id = $db->lastInsertRowid();
         //upload file
         if ($file) {
             $upload_dir = DIR_SUBMISSION_FILES . '/' . $id;
             try {
                 checkFileType($file['name'], array("jpg", "jpeg", "gif", "png"));
                 uploadFile($file['tmp_name'], $upload_dir, $file['name']);
             } catch (Exception $e) {
                 // delete entry if upload failed
                 $db->deleteSubmission($id);
                 throw new RestException(400, $e->getMessage());
             }
         }
         return $db->getSubmission($id);
         // modify entry
     } else {
         //insert Model and return it
         $db = new SubmissionDatabase();
         $db->insertSubmission($data);
         return $db->getSubmission($id);
     }
 }
开发者ID:andreasunteidig,项目名称:meetingPoint,代码行数:59,代码来源:index.php

示例12: add

 function add($data)
 {
     unset($data['section']);
     $data['createdby'] = USER_ID;
     // upload image logo
     $image = uploadFile("image", BASEPATH . "../public/images/upload/");
     if (!empty($image['file_name'])) {
         $data['image'] = $image['file_name'];
     }
     return $this->db->insert($this->_table, $data);
 }
开发者ID:duongbaphuc1,项目名称:newcanho,代码行数:11,代码来源:news_model.php

示例13: add

 function add($data)
 {
     unset($data['section']);
     unset($data['old_image']);
     $data['createdby'] = USER_ID;
     // upload image logo
     $image = uploadFile("product_image", BASEPATH . "../public/images/products/");
     if (!empty($image['file_name'])) {
         $data['product_image'] = $image['file_name'];
     }
     return $this->db->insert("products", $data);
 }
开发者ID:duongbaphuc1,项目名称:newcanho,代码行数:12,代码来源:products_model.php

示例14: add

 function add($data)
 {
     $array = array();
     $array['brand_en'] = $data['brand_en'];
     $array['brand_vi'] = $data['brand_vi'];
     // upload image logo
     $image_logo = uploadFile("logo", BASEPATH . "../public/images/customers/");
     if (!empty($image_logo['file_name'])) {
         $array['logo'] = $image_logo['file_name'];
     }
     $array['createdby'] = USER_ID;
     return $this->db->insert("customers", $array);
 }
开发者ID:duongbaphuc1,项目名称:newcanho,代码行数:13,代码来源:customers_model.php

示例15: edit

 function edit($data, $code)
 {
     $array = array();
     $array['content_en'] = $data['content_en'];
     $array['content_vi'] = $data['content_vi'];
     // upload image logo
     $image_logo = uploadFile("image", BASEPATH . "../public/images/statics/");
     if (!empty($image_logo['file_name'])) {
         $array['image'] = $image_logo['file_name'];
         removeFile(BASEPATH . "../public/images/statics/" . $_POST['old_image']);
     }
     return $this->db->update('static_contents', $array, array('code' => $code));
 }
开发者ID:duongbaphuc1,项目名称:newcanho,代码行数:13,代码来源:staticcontent_model.php


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