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


PHP upload_file函数代码示例

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


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

示例1: upload_zip

function upload_zip($zip_file = '')
{
    // Create temporary directory
    exec('mktemp -d', $output, $rc);
    if ($rc != 0) {
        die('mktemp failed');
    }
    $temp_dir = $output[0];
    if (!is_dir($temp_dir)) {
        die('Temporary directory not created');
    }
    // Unzip
    system("unzip -q -d {$temp_dir} {$zip_file}", $rc);
    if ($rc != 0) {
        die('unzip failed');
    }
    unlink($zip_file);
    // Fetch directory listing
    $file_list = glob("{$temp_dir}/*");
    // Fetch file information
    $files = array();
    foreach ($file_list as $file) {
        if (!preg_match('/\\.pdf$/', $file)) {
            continue;
        }
        upload_file($file, basename($file));
    }
}
开发者ID:lopacinski,项目名称:WebFinance,代码行数:28,代码来源:upload.php

示例2: generate_thumbnail

function generate_thumbnail($sURL, $needConnect)
{
    if (!is_logged_in()) {
        return getError("no logged-in user");
    }
    $res = array();
    //get picture from service
    //"http://www.sitepoint.com/forums/image.php?u=106816&dateline=1312480118";
    $remote_path = str_replace("[URL]", $sURL, WEBSITE_THUMBNAIL_SERVICE);
    $heurist_path = tempnam(HEURIST_FILESTORE_DIR, "_temp_");
    // . $file_id;
    $filesize = saveURLasFile($remote_path, $heurist_path);
    if ($filesize > 0) {
        //check the dimension of returned thumbanil in case it less than 50 - consider it as error
        if (strpos($remote_path, substr(WEBSITE_THUMBNAIL_SERVICE, 0, 24)) == 0) {
            $image_info = getimagesize($heurist_path);
            if ($image_info[1] < 50) {
                //remove temp file
                unlink($heurist_path);
                return getError("Thumbnail generator service can't create the image for specified URL");
            }
        }
        $fileID = upload_file("snapshot.jpg", "jpg", $heurist_path, null, $filesize, $sURL, $needConnect);
        if (is_numeric($fileID)) {
            $res = get_uploaded_file_info($fileID, $needConnect);
        } else {
            $res = getError("File upload was interrupted. " . $fileID);
        }
    } else {
        $res = getError("Cannot download image");
    }
    return $res;
}
开发者ID:HeuristNetwork,项目名称:heurist,代码行数:33,代码来源:saveURLasFile.php

示例3: insert_file

function insert_file($var, $upload_path, $file_name_prefix)
{
    if (isset($_REQUEST['is_' . $var]) && $_REQUEST['is_' . $var] && isset($_FILES[$var])) {
        return upload_file($var, $upload_path, $file_name_prefix);
    }
    return '';
}
开发者ID:ivanovv,项目名称:metro4all,代码行数:7,代码来源:lib.upload.php

示例4: upload_file_and_edit_agreement

function upload_file_and_edit_agreement()
{
    save_agreement();
    upload_file(3, 10, $_POST['0'], 1);
    $id = $_POST['0'];
    $aggr = db_retrieve_agreement_byID($id);
    addedit_agreement($aggr);
}
开发者ID:TIS-FMDP,项目名称:Erasmus,代码行数:8,代码来源:agreements.php

示例5: upImg

 /**
  *
  * @param type $data
  * @param type $type
  * @return string
  */
 public static function upImg($data, $type = 'jpg')
 {
     if (!self::isImg(strtolower($type))) {
         return FALSE;
     }
     $server = getC("upload_server");
     $sign = getC("upload_sign");
     $file_url = upload_file($server, $data, $type, $sign);
     return $file_url;
 }
开发者ID:lingPro,项目名称:zj_web_demo,代码行数:16,代码来源:UploadImgHandler.class.php

示例6: upload

/**
 * Master function for uploading, checks filenames and generates thumbnails
 */
function upload($file, $dir = 'uploads')
{
    $filename = check_filename($file['name'], $dir);
    // Pop the original file in /uploads/originals
    move_uploaded_file($file['tmp_name'], $dir . '/originals/' . $filename);
    // Generate thumbnail
    upload_file($filename, $file['type'], 100, 100, 'thumbnails', $dir);
    // Generate stream image
    upload_file($filename, $file['type'], 350, 500, 'stream', $dir);
    return $filename;
}
开发者ID:Geekathon,项目名称:rat,代码行数:14,代码来源:upload.php

示例7: uploads

 /**
  * 上传文件 uploads
  */
 public function uploads()
 {
     if (IS_POST) {
         /* 定义变量 */
         $RESPONSE_STATUS = 500;
         /* 上传图片 */
         $resultUploads = upload_file();
         if ($resultUploads['result'] == 1) {
             $RESPONSE_STATUS = 100;
         }
         $result = array('Tips' => $resultUploads['msg'], 'RESPONSE_STATUS' => $RESPONSE_STATUS, 'RESPONSE_INFO' => $resultUploads['msg']);
         $this->ajaxReturn($result);
     }
 }
开发者ID:liqihua,项目名称:yanzhihui,代码行数:17,代码来源:ApiController.class.php

示例8: upload_do

 public function upload_do()
 {
     if (isset($_FILES['file'])) {
         $tArr = explode(".", $_FILES["file"]["name"]);
         $type = $tArr[count($tArr) - 1];
         $filename = $_FILES["file"]["tmp_name"];
         $handle = fopen($filename, "r");
         $data = fread($handle, filesize($filename));
         fclose($handle);
         $server = getC("upload_server");
         $sign = getC("upload_sign");
         echo upload_file($server, $data, $type, $sign);
     }
 }
开发者ID:lingPro,项目名称:zj_web_demo,代码行数:14,代码来源:IndexAction.class.php

示例9: refund_apply_order_goods_upload_ex

function refund_apply_order_goods_upload_ex($refund, $pic_name, $upload_size_limit)
{
    if ($refund[$pic_name]) {
        if ($_FILES[$pic_name]['size'] / 1024 > $upload_size_limit) {
            $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['upload_file_limit'], $upload_size_limit));
            return -1;
        }
        $refund_pic1 = upload_file($_FILES[$pic_name], 'feedbackimg');
        if ($refund_pic1 === false) {
            $GLOBALS['err']->add("无法上传");
            return -1;
        }
    } else {
        $refund_pic1 = '';
    }
    return $refund_pic1;
}
开发者ID:shiruolin,项目名称:hzzshop,代码行数:17,代码来源:lib_return.php

示例10: add_details

 function add_details()
 {
     $data = filter_forwarded_data($this);
     if (!empty($_FILES)) {
         $fileUrl = upload_file($_FILES, 'plantemplate__fileurl', 'plan_', 'xls');
         if (!empty($fileUrl)) {
             $_POST['document'] = $fileUrl;
             $data['list'] = $this->_procurement_plan->add_details($_POST);
             if (!is_array($data['list'])) {
                 $data['msg'] = 'ERROR: ' . $data['list'];
             }
             $this->load->view('procurement_plans/plan_details', $data);
         } else {
             echo format_notice($this, 'ERROR: The plan document could not be uploaded.');
         }
     } else {
         echo format_notice($this, 'ERROR: No plan details could be resolved.');
     }
 }
开发者ID:nwtug,项目名称:pss-version-1.0,代码行数:19,代码来源:procurement_plans.php

示例11: settings

 function settings()
 {
     $data = filter_forwarded_data($this);
     logout_invalid_user($this);
     # user has posted the settings form
     if (!empty($_POST)) {
         # Upload the photo if any exists before you proceed with the rest of the process
         $_POST['photo_url'] = !empty($_FILES) ? upload_file($_FILES, 'newphoto__fileurl', 'photo_' . $this->native_session->get('__user_id') . '_', 'png,jpg,jpeg,tiff') : '';
         $result = $this->_user->settings($_POST);
         if ($result['boolean']) {
             $this->native_session->set('msg', 'Your settings have been updated');
         } else {
             echo "ERROR: The settings could not be updated. " . $result['reason'];
         }
     } else {
         $data['user'] = $this->_user->details();
         $this->load->view('users/settings', $data);
     }
 }
开发者ID:nwtug,项目名称:pss-version-1.0,代码行数:19,代码来源:users.php

示例12: MOH_Files_Modify

function MOH_Files_Modify()
{
    global $mysqli;
    include dirname(__FILE__) . '/../include/config.inc.php';
    $session =& $_SESSION['MOH_Files_Modify'];
    $Message = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : "";
    $smarty = smarty_init(dirname(__FILE__) . '/templates');
    $action = $_REQUEST['action'];
    if ($action == 'uploadfile') {
        $FK_Group = $_REQUEST['id_group'];
        $bigFK_Group = str_pad($FK_Group, 10, "0", STR_PAD_LEFT);
        $uploadPath = $conf['dirs']['moh'] . "/group_" . $bigFK_Group . "/";
        $filename_ext = explode(".", $_FILES['file']['name']['0']);
        $filename = "";
        for ($i = 0; $i < count($filename_ext) - 1; $i++) {
            $filename .= $filename_ext[$i];
        }
        $extension = $filename_ext[count($filename_ext) - 1];
        $query = "SELECT MAX(`Order`) FROM Moh_Files WHERE FK_Group = '{$FK_Group}'";
        $result = $mysqli->query($query) or die($mysqli->error);
        $row = $result->fetch_row();
        $order = $row['0'] + 1;
        $Errors = upload_file($uploadPath, $filename, $extension, $order, $FK_Group);
        if (empty($Errors)) {
            asterisk_UpdateConf('musiconhold.conf');
            asterisk_Reload();
            header("Location: MOH_Files_ListGroup.php?PK_Group={$FK_Group}");
            die;
        }
    }
    // Init available groups (Groups)
    $query = "SELECT * FROM Moh_Groups";
    $result = $mysqli->query($query) or die($mysqli->error . $query);
    while ($row = $result->fetch_assoc()) {
        $Groups[] = $row;
    }
    $smarty->assign('Groups', $Groups);
    $smarty->assign('Message', $Message);
    $smarty->assign('Errors', $Errors);
    return $smarty->fetch('MOH_Files_Modify.tpl');
}
开发者ID:rakesh-mohanta,项目名称:yunapbx,代码行数:41,代码来源:MOH_Files_Modify.php

示例13: add

 function add()
 {
     $data = filter_forwarded_data($this);
     logout_invalid_user($this);
     if (!empty($_POST)) {
         # Upload the file before you proceed with the rest of the process
         $fileUrl = upload_file($_FILES, 'document__fileurl', 'document_', 'pdf,doc,docx,zip,zipx,rar');
         if (!empty($fileUrl)) {
             $_POST['document'] = $fileUrl;
             $result = $this->_document->add($_POST);
         } else {
             $result = array('boolean' => FALSE, 'reason' => 'File could not be uploaded.');
         }
         if (!$result['boolean']) {
             echo "ERROR: The document could not be added. " . $result['reason'];
         }
     } else {
         $data['area'] = !empty($data['a']) ? $data['a'] : 'system';
         $this->load->view('documents/new_document', $data);
     }
 }
开发者ID:nwtug,项目名称:pss-version-1.0,代码行数:21,代码来源:documents.php

示例14: updateproduct

function updateproduct()
{
    global $db;
    $image = '';
    $newest = $_FILES['prodd_image']['name'];
    foreach ($newest as $key => $value) {
        $imgg = upload_file($key, $value, 'prod_img/');
        if ($imgg != '') {
            $image .= $imgg . '|';
        }
    }
    //echo $image.'image---<br/>';
    $id = $_POST['hd_id'];
    $sth = $db->prepare("SELECT * FROM product where `id`=?");
    $sth->execute(array($id));
    $result = $sth->fetch();
    //echo $result['prod_img'].'dbimg';
    $imagee = $result['prod_img'] . $image;
    //echo $imagee.'imag<br/>';
    $db->exec("update `product` set `product_name`='{$_POST['name']}',`category_id`='{$_POST['category']}',`prod_img`='{$imagee}',`description`='{$_POST['descp']}' where `id`='{$_POST['hd_id']}'");
    header("location:add_product.php");
}
开发者ID:jyotiprava,项目名称:45serverbackup,代码行数:22,代码来源:function.php

示例15: UploadDocs

/**
 * Created by PhpStorm.
 * User: spider-ninja
 * Date: 8/14/16
 * Time: 8:47 PM
 */
function UploadDocs($dataDir, $localId)
{
    $outArray = array('photo' => 0, 'pv' => 0, 'adhar_card' => 0, 'voter_card' => 0, 'driving_license' => 0, 'pan_card' => 0);
    //$files1 = scandir($dataDir);
    if (file_exists($dataDir . $localId . "/" . $localId . ".jpg")) {
        $outArray['photo'] = upload_file($dataDir . $localId . "/" . $localId . ".jpg");
    }
    if (file_exists($dataDir . $localId . "/aadhar.pdf")) {
        $outArray['adhar_card'] = upload_file($dataDir . $localId . "/aadhar.pdf");
    }
    if (file_exists($dataDir . $localId . "/pv.pdf")) {
        $outArray['pv'] = upload_file($dataDir . $localId . "/pv.pdf");
    }
    if (file_exists($dataDir . $localId . "/votor_card.pdf")) {
        $outArray['voter_card'] = upload_file($dataDir . $localId . "/votor_card.pdf");
    }
    if (file_exists($dataDir . $localId . "/driving_license.pdf")) {
        $outArray['driving_license'] = upload_file($dataDir . $localId . "/driving_license.pdf");
    }
    if (file_exists($dataDir . $localId . "/pan.pdf")) {
        $outArray['pan_card'] = upload_file($dataDir . $localId . "/pan.pdf");
    }
    return $outArray;
}
开发者ID:rajnishp,项目名称:api_bluenet,代码行数:30,代码来源:uploadDocs.php


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