本文整理汇总了PHP中upload_file函数的典型用法代码示例。如果您正苦于以下问题:PHP upload_file函数的具体用法?PHP upload_file怎么用?PHP upload_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了upload_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: upload_file_editor
/**
* 编辑器上传文件 upload_file_editor
* @param $path
*/
function upload_file_editor($path = NULL)
{
/* 定义参数 */
$dir_name = ucfirst(I('get.dir'));
if (!$path) {
$path = CONTROLLER_NAME;
}
$savePath = './Editor/' . $dir_name . '/' . $path . '/';
//上传地址
$saveUrl = '/Uploads/Editor/' . $dir_name . '/' . $path . '/';
//读取地址
switch ($dir_name) {
case 'Flash':
$options = array('maxSize' => 1024 * 1024 * 2, 'exts' => array('swf', 'flv'), 'savePath' => $savePath);
break;
case 'Media':
$options = array('maxSize' => 1024 * 1024 * 5, 'exts' => array('swf', 'flv', 'mp3', 'wav', 'wma', 'wmv', 'mid', 'avi', 'mpg', 'asf', 'rm', 'rmvb'), 'savePath' => $savePath);
break;
case 'File':
$options = array('maxSize' => 1024 * 1024 * 5, 'exts' => array('doc', 'docx', 'xls', 'xlsx', 'ppt', 'htm', 'html', 'txt', 'zip', 'rar', 'gz', 'bz2'), 'savePath' => $savePath);
break;
default:
$options = array('maxSize' => 1024 * 1024 * 0.5, 'exts' => array('jpg', 'jpeg', 'gif', 'png'), 'savePath' => $savePath);
}
/* 上传文件 */
$result = upload_file($options);
if ($result['result'] == 1) {
//上传成功
$return['error'] = 0;
$return['url'] = $saveUrl . $result['msg'];
} else {
$return['error'] = 1;
$return['message'] = $result['msg'];
}
return $return;
}
开发者ID:liqihua,项目名称:yanzhihui,代码行数:40,代码来源:function.php
示例17: get_image_size
}
//检测链接图片的尺寸
if ($check_info == 1 && !check_image_type($_FILES["linkImage"]["name"])) {
$check_info = 0;
$action = $mark_id != "" ? "edit" : "add";
$ActionMessage = $strCategoryImage . $strImgTypeMemo;
}
if ($check_info == 1 && $_FILES["linkImage"]["name"] != "") {
$arrISize = get_image_size($_FILES["linkImage"]["tmp_name"]);
if ($arrISize[1] > 16 && $arrISize[3] > 16) {
$check_info = 0;
$ActionMessage = $strCategoryImageError;
$action = $mark_id != "" ? "edit" : "add";
} else {
//上传图片
$linkImage = upload_file($_FILES["linkImage"]["tmp_name"], $_FILES["linkImage"]["name"], "../attachments");
}
} else {
$linkImage = "";
}
if ($check_info == 1) {
if ($mark_id != "") {
//编辑
$rsexits = getFieldValue($DBPrefix . "keywords", "keyword='" . encode($_POST['name']) . "'", "id");
if ($rsexits != $mark_id && $rsexits != "") {
$ActionMessage = "{$strDataExists}";
$action = "edit";
} else {
if ($linkImage != "") {
$sql = "update " . $DBPrefix . "keywords set keyword='" . encode($_POST['name']) . "',linkUrl='" . encode($_POST['linkUrl']) . "',linkImage='" . encode($linkImage) . "' where id='{$mark_id}'";
} else {
开发者ID:BGCX067,项目名称:f2cont-svn-to-git,代码行数:31,代码来源:keywords.php
示例18: action_act_supplier_reg
function action_act_supplier_reg()
{
// 获取全局变量
$_LANG = $GLOBALS['_LANG'];
$smarty = $GLOBALS['smarty'];
$db = $GLOBALS['db'];
$ecs = $GLOBALS['ecs'];
$user_id = $_SESSION['user_id'];
$supplier_name = isset($_POST['supplier_name']) ? trim($_POST['supplier_name']) : '';
$rank_id = isset($_POST['rank_id']) ? intval($_POST['rank_id']) : 0;
$company_name = isset($_POST['company_name']) ? trim($_POST['company_name']) : '';
$country = isset($_POST['country']) ? intval($_POST['country']) : 1;
$province = isset($_POST['province']) ? intval($_POST['province']) : 1;
$city = isset($_POST['city']) ? intval($_POST['city']) : 1;
$district = isset($_POST['district']) ? intval($_POST['district']) : 1;
$country = isset($_POST['country']) ? intval($_POST['country']) : 1;
$address = isset($_POST['address']) ? trim($_POST['address']) : '';
$tel = isset($_POST['tel']) ? trim($_POST['tel']) : '';
$guimo = isset($_POST['guimo']) ? trim($_POST['guimo']) : '';
$email = isset($_POST['email']) ? trim($_POST['email']) : '';
$company_type = isset($_POST['company_type']) ? trim($_POST['company_type']) : '';
$bank = isset($_POST['bank']) ? trim($_POST['bank']) : '';
$contact = isset($_POST['contact']) ? trim($_POST['contact']) : '';
$contact_back = isset($_POST['contact_back']) ? trim($_POST['contact_back']) : '';
$contact_shop = isset($_POST['contact_shop']) ? trim($_POST['contact_shop']) : '';
$contact_yunying = isset($_POST['contact_yunying']) ? trim($_POST['contact_yunying']) : '';
$contact_shouhou = isset($_POST['contact_shouhou']) ? trim($_POST['contact_shouhou']) : '';
$contact_caiwu = isset($_POST['contact_caiwu']) ? trim($_POST['contact_caiwu']) : '';
$contact_jishu = isset($_POST['contact_jishu']) ? trim($_POST['contact_jishu']) : '';
$add_time = gmtime();
/* 图片上传处理 */
$upload_size_limit = $_CFG['upload_size_limit'] == '-1' ? ini_get('upload_max_filesize') : $_CFG['upload_size_limit'];
$last_char = strtolower($upload_size_limit[strlen($upload_size_limit) - 1]);
switch ($last_char) {
case 'm':
$upload_size_limit *= 1024 * 1024;
break;
case 'k':
$upload_size_limit *= 1024;
break;
}
if (isset($_FILES['zhizhao']) && $_FILES['zhizhao']['tmp_name'] != '' && isset($_FILES['zhizhao']['tmp_name']) && $_FILES['zhizhao']['tmp_name'] != 'none') {
if ($_FILES['zhizhao']['size'] / 1024 > $upload_size_limit) {
$err->add(sprintf($_LANG['upload_file_limit'], $upload_size_limit));
$err->show($_LANG['back_up_page']);
}
$zhizhao_img = upload_file($_FILES['zhizhao'], 'supplier');
if ($zhizhao_img === false) {
$err->add('业执照图片上传失败!');
$err->show($_LANG['back_up_page']);
} else {
$sql_img = "zhizhao='{$zhizhao_img}',";
}
}
if (isset($_FILES['id_card']) && $_FILES['id_card']['tmp_name'] != '' && isset($_FILES['id_card']['tmp_name']) && $_FILES['id_card']['tmp_name'] != 'none') {
if ($_FILES['id_card']['size'] / 1024 > $upload_size_limit) {
$err->add(sprintf($_LANG['upload_file_limit'], $upload_size_limit));
$err->show($_LANG['back_up_page']);
}
$id_card_img = upload_file($_FILES['id_card'], 'supplier');
if ($id_card_img === false) {
$err->add('身份证图片上传失败!');
$err->show($_LANG['back_up_page']);
} else {
$sql_img .= "id_card='{$id_card_img}', ";
}
}
$sql = "select supplier_id from " . $ecs->table('supplier') . " where user_id='{$user_id}' ";
$supplier_id = $db->getOne($sql);
if ($supplier_id) {
$mes = '供货商申请修改成功,已经重新进入审核流程,请留意审核结果!';
$sql = "update " . $ecs->table('supplier') . " set supplier_name='{$supplier_name}', rank_id='{$rank_id}', company_name='{$company_name}', " . "country='{$country}', province='{$province}', city='{$city}', district='{$district}', address='{$address}', tel='{$tel}', guimo='{$guimo}', email='{$email}', " . "company_type='{$company_type}', bank='{$bank}', " . $sql_img . " contact='{$contact}', contact_back='{$contact_back}', contact_shop='{$contact_shop}', contact_yunying='{$contact_yunying}', contact_shouhou='{$contact_shouhou}', contact_caiwu='{$contact_caiwu}', contact_jishu='{$contact_jishu}'," . "status='0' " . " where supplier_id='{$supplier_id}' ";
} else {
$mes = '供货商申请提交成功,已经进入审核流程,请留意审核结果!';
$sql = "insert into " . $ecs->table('supplier') . "(user_id, supplier_name, rank_id, company_name, country, province, city, district, address, tel, guimo, email," . "company_type, bank, zhizhao, id_card, contact, contact_back, contact_shop, contact_yunying, contact_shouhou, contact_caiwu, contact_jishu, add_time) " . " values('{$user_id}', '{$supplier_name}', '{$rank_id}', '{$company_name}', '{$country}', '{$province}', '{$city}', '{$district}', '{$address}', '{$tel}', '{$guimo}', '{$email}', " . "'{$company_type}', '{$bank}', '{$zhizhao_img}', '{$id_card_img}', '{$contact}', '{$contact_back}', '{$contact_shop}', '{$contact_yunying}', '{$contact_shouhou}', '{$contact_caiwu}', '{$contact_jishu}', '{$add_time}')";
}
$db->query($sql);
show_message($mes, '返回上一页', 'user.php?act=supplier_reg', 'info');
}
开发者ID:seanguo166,项目名称:yinoos,代码行数:79,代码来源:user.php
示例19: array
$result = array();
$files = diverse_array($files);
foreach ($files as $file) {
$f = new UploadedFile();
$f->name = $file['name'];
$f->mime = $file['type'];
$f->size = $file['size'];
$f->tempfile = $file['tmp_name'];
$f->error = $file['error'];
// 'expire' doesn't exist neither in $_FILES nor in UploadedFile;
// commented out for future implementation
//$f->expire = $file['expire'];
$result[] = $f;
}
return $result;
}
$type = isset($_GET['output']) ? $_GET['output'] : 'json';
$response = new Response($type);
if (isset($_FILES['files'])) {
$uploads = refiles($_FILES['files']);
try {
foreach ($uploads as $upload) {
$res[] = upload_file($upload);
}
$response->send($res);
} catch (Exception $e) {
$response->error($e->getCode(), $e->getMessage());
}
} else {
$response->error(400, 'No input file(s)');
}
开发者ID:LolcatsV2,项目名称:Pomf,代码行数:31,代码来源:upload.php
示例20: upload_file
<?php
function upload_file($file)
{
if ($file['name'] == '') {
echo 'Файл не выбран!';
return;
}
if (copy($file['tmp_name'], 'img/' . $file['name'])) {
echo 'Файл успешно загружен';
} else {
echo 'Ошибка загрузки файла';
}
}
if (isset($_FILES['file'])) {
upload_file($_FILES['file']);
}
开发者ID:project-hh,项目名称:php,代码行数:17,代码来源:загрузка+файла.php
注:本文中的upload_file函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论