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


PHP sendFile函数代码示例

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


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

示例1: play

function play($idResource, $idParams, $back_url)
{
    //if(!checkPerm('view', true, 'organization') && !checkPerm('view', true, 'storage')) die("You can't access");
    //echo ("idResource = ".$idResource."; idParams = ".$idParams."; back_url = ".$back_url);
    list($file) = sql_fetch_row(sql_query("SELECT path" . " FROM " . $GLOBALS['prefix_lms'] . "_materials_lesson" . " WHERE idLesson = '" . $idResource . "'"));
    //recognize mime type
    $expFileName = explode('.', $file);
    $totPart = count($expFileName) - 1;
    require_once $GLOBALS['where_lms'] . '/lib/lib.param.php';
    $idReference = getLOParam($idParams, 'idReference');
    // NOTE: Track only if $idReference is present
    if ($idReference !== FALSE) {
        require_once $GLOBALS['where_lms'] . '/class.module/track.item.php';
        list($exist, $idTrack) = Track_Item::getIdTrack($idReference, getLogUserId(), $idResource, TRUE);
        if ($exist) {
            $ti = new Track_Item($idTrack);
            $ti->setDate(date('Y-m-d H:i:s'));
            $ti->status = 'completed';
            $ti->update();
        } else {
            $ti = new Track_Item(false);
            $ti->createTrack($idReference, $idTrack, getLogUserId(), date('Y-m-d H:i:s'), 'completed', 'item');
        }
    }
    if ($_SESSION['direct_play'] == 1) {
        if (isset($_SESSION['idCourse'])) {
            TrackUser::closeSessionCourseTrack();
            unset($_SESSION['idCourse']);
            unset($_SESSION['idEdition']);
        }
        if (isset($_SESSION['test_assessment'])) {
            unset($_SESSION['test_assessment']);
        }
        if (isset($_SESSION['cp_assessment_effect'])) {
            unset($_SESSION['cp_assessment_effect']);
        }
        $_SESSION['current_main_menu'] = '1';
        $_SESSION['sel_module_id'] = '1';
        $_SESSION['is_ghost'] = false;
    }
    //send file
    sendFile('/appLms/' . Get::sett('pathlesson'), $file, $expFileName[$totPart]);
}
开发者ID:abhinay100,项目名称:forma_app,代码行数:43,代码来源:do.item.php

示例2: downloadcourse

 function downloadcourse()
 {
     checkPerm('view_info');
     require_once _base_ . '/lib/lib.download.php';
     //find selected file
     list($filename) = sql_fetch_row(sql_query("\r\n\tSELECT path \r\n\tFROM " . $GLOBALS['prefix_lms'] . "_course_file \r\n\tWHERE id_course='" . $_SESSION['idCourse'] . "' AND id_file = '" . (int) $_GET['id'] . "'"));
     if (!$filename) {
         $GLOBALS['page']->add(getErrorUi('Sorry, such file does not exist!'), 'content');
         return;
     }
     //recognize mime type
     $extens = array_pop(explode('.', $filename));
     sendFile(_PATH_COURSE, $filename, $extens);
 }
开发者ID:abhinay100,项目名称:forma_app,代码行数:14,代码来源:infocourse.php

示例3: session_start

    $format = $query_arr["format"];
    $cmd = $query_arr["cmd"];
    $ctype = "application/zip";
    if ($format == 'CSV') {
        $ctype = "text/csv";
    }
    //check if user is guest
    session_start();
    $user = null;
    if (isset($_SESSION["user_name"])) {
        $user = $_SESSION["user_name"];
    }
    if ($user != null && $user == 'guest') {
        throw new Exception("Guest users are not allowed to export data!");
    }
    //check user session and permissions
    if (!Helpers::isValidUserProj($map)) {
        throw new Exception("Session time out or unathorized access!");
    }
    //check command
    if ($cmd == 'prepare') {
        echo json_encode(["success" => true, "message" => prepareFile($layername, $map, $query_arr, $format)]);
    } elseif ($cmd == 'get') {
        $key = $query_arr["key"];
        sendFile($ctype, $key);
    }
} catch (Exception $e) {
    //header('Server Error', true, 500);
    echo json_encode(["success" => false, "message" => $e->getMessage()]);
    exit;
}
开发者ID:vicente-medina,项目名称:gisapp,代码行数:31,代码来源:export.php

示例4: switch

    switch ($do) {
        case "download":
            uses("attachment");
            $attachment = new Attachments();
            if (empty($_GET['aid'])) {
                flash();
            }
            $attach_id = authcode(rawurldecode($_GET['aid']), "DECODE");
            if (empty($attach_id)) {
                flash();
            }
            require LIB_PATH . "func.download.php";
            require LIB_PATH . "js.class.php";
            $filename = rawurlencode($attachment->getAttachFileName($attach_id));
            $filename = $attachment->file_url;
            if (!sendFile($filename)) {
                exit('Error occured when get files.');
            } else {
                JS::Close();
            }
            break;
        default:
            break;
    }
}
if (empty($_GET['id'])) {
    $picture_src = URL . "images/watermark.png";
}
if (isset($_GET['source'])) {
    $file_source = trim(rawurldecode($_GET['source']));
    $picture_src = URL . $attachment_url . $file_source;
开发者ID:renduples,项目名称:alibtob,代码行数:31,代码来源:misc.php

示例5: define

<?php

require_once './config.php';
require_once '../../php/xmlrpc.php';
define('USE_NGINX', false);
define('SCHEME', 'https');
if (!isset($_GET['f']) || empty($_GET['f']) || !file_exists($_GET['f']) || !preg_match('/.(avi|mkv|ts|mp4|flv|wmv|mpe?g|ogg|wma|mp3|flac)$/i', $_GET['f'])) {
    header('HTTP/1.0 404 Not Found');
    exit;
}
if (USE_NGINX) {
    header("Content-Type: application/octet-stream");
    header("X-Accel-Redirect: /stream{$_GET['f']}");
} else {
    sendFile($_GET['f']);
}
开发者ID:BlackPearl01,项目名称:quick-box,代码行数:16,代码来源:stream.php

示例6: dirname

include '../../../include/db.php';
include '../../../include/authenticate.php';
include '../../../include/general.php';
include '../../../include/resource_functions.php';
include_once dirname(__FILE__) . "/../include/utility.php";
$ref = getvalescaped('ref', 0, true);
$size = getvalescaped('size', '');
$page = getvalescaped('page', 1, true);
$alternative = getvalescaped('alt', -1, true);
$resource = get_resource_data($ref);
if (!resource_download_allowed($ref, $size, $resource["resource_type"])) {
    # This download is not allowed.
    exit("Permission denied");
}
$width = getvalescaped('width', 0, true);
$height = getvalescaped('height', 0, true);
if ($width == 0 && $height == 0) {
    $format = getImageFormat($size);
    $width = (int) $format['width'];
    $height = (int) $format['height'];
}
$ext = getvalescaped('ext', getDefaultOutputFormat());
$profile = getProfileFileName(getvalescaped('profile', null));
$baseDirectory = get_temp_dir() . '/format_chooser';
@mkdir($baseDirectory);
$target = $baseDirectory . '/' . getTargetFilename($ref, $ext, $size);
set_time_limit(0);
convertImage($resource, $page, $alternative, $target, $width, $height, $profile);
sendFile($target);
unlink($target);
开发者ID:claytondaley,项目名称:resourcespace,代码行数:30,代码来源:convert.php

示例7: connectMysql

<?php

require 'local/config.inc.php';
require 'common.inc.php';
require 'mysql.inc.php';
connectMysql();
$file = '';
if ($_GET['sound'] == 'newplayer') {
    $res = $DB->query("SELECT * FROM ressnd WHERE grp = 'Credits' AND name = 'NewPlayers'");
    $rs = $res->fetch();
    $vals = explode(',', $rs['val']);
    $num = intval($_GET['num']);
    $file = '../res-full/' . $rs['resfolder'] . '/' . $vals[$num % sizeof($vals)] . '.' . strtr(substr($_GET['type'], 0, 3), './', '--');
}
if ($file && file_exists($file)) {
    sendFile($file);
}
header('HTTP/1.0 404 Not Found');
开发者ID:Mwyann,项目名称:ydkjs,代码行数:18,代码来源:soundeffect.php

示例8: var_dump

     $ext['a'] = "a";
     $ext['b'] = "b";
     var_dump(sendVedio($filePath, $from = "admin", $target_type, $target, $filename, $length, $thumb, $thumb_secret, $ext));
     break;
 case 40:
     //发文件消息
     $filePath = "./resource/up/a.rar";
     $from = 'admin';
     $target_type = "users";
     $target = array("zhangsan", "lisi");
     $filename = "a.rar";
     $length = 10;
     //时长
     $ext['a'] = "a";
     $ext['b'] = "b";
     var_dump(sendFile($filePath, $from = "admin", $target_type, $target, $filename, $length, $ext));
     break;
 case 41:
     //获取app中的所有群组-----不分页(默认返回10个)
     var_dump(getGroups());
     break;
 case 42:
     ////获取app中的所有群组--------分页
     $cursor = readCursor("groupfile.txt");
     var_dump($cursor);
     var_dump(getGroupsForPage(2, $cursor));
     break;
 case 43:
     //获取一个或多个群组的详情
     $group_ids = array("1445830526109", "1445833238210");
     var_dump(getGroupDetail($group_ids));
开发者ID:lzstg,项目名称:emchat,代码行数:31,代码来源:easemobtest.php

示例9: do_mysql_dump

function do_mysql_dump($encode = "utf8")
{
    global $DBCFG;
    $tables = $DBCFG[DBprefix] . 'config,' . $DBCFG[DBprefix] . 'tema,' . $DBCFG[DBprefix] . 'tabla_rel,' . $DBCFG[DBprefix] . 'indice,' . $DBCFG[DBprefix] . 'usuario,' . $DBCFG[DBprefix] . 'notas,' . $DBCFG[DBprefix] . 'values,' . $DBCFG[DBprefix] . 'tvocab,' . $DBCFG[DBprefix] . 'term2tterm,' . $DBCFG[DBprefix] . 'uri';
    /*
     * To UTF-8 databases
     */
    if ($encode == 'utf8') {
        $setUTF = SQL("SET NAMES", "utf8");
        $setUTF1 = SQL("SET CHARACTER SET", "utf8");
    }
    //get  the tables
    $tables = explode(',', $tables);
    //cycle through
    foreach ($tables as $table) {
        $result = SQL('SELECT', ' * FROM ' . $table);
        $num_fields = $result->_numOfFields;
        $return .= 'DROP TABLE IF EXISTS ' . $table . '; ';
        $row2query = SQL('SHOW CREATE TABLE', $table);
        $row2data = $row2query->FetchRow();
        $return .= "\n\n" . $row2data["Create Table"] . ";\n\n";
        for ($i = 0; $i < $num_fields; $i++) {
            while ($row = $result->FetchRow()) {
                $return .= 'INSERT INTO ' . $table . ' VALUES(';
                for ($j = 0; $j < $num_fields; $j++) {
                    $row[$j] = addslashes($row[$j]);
                    $row[$j] = $data = arrayReplace(array("\n"), array("\\n"), $row[$j]);
                    if (isset($row[$j])) {
                        $return .= '"' . $row[$j] . '"';
                    } else {
                        $return .= '""';
                    }
                    if ($j < $num_fields - 1) {
                        $return .= ',';
                    }
                }
                $return .= ");\n";
            }
        }
        $return .= "\n\n\n";
    }
    sendFile($return, string2url('TemaTres-' . $_SESSION[CFGTitulo]) . '.sql');
}
开发者ID:kodizant,项目名称:TemaTres-Vocabulary-Server,代码行数:43,代码来源:fun.admin.php

示例10: forumDispatch


//.........这里部分代码省略.........
            addthread();
            break;
        case "insthread":
            insthread();
            break;
            //-----------------------------------------------//
        //-----------------------------------------------//
        case "modthread":
            modthread();
            break;
        case "movethread":
            $id_thread = importVar('id_thread', true, 0);
            $id_forum = importVar('id_forum', true, 0);
            moveThread($id_thread, $id_forum);
            break;
        case "upthread":
            upthread();
            break;
            //-----------------------------------------------//
        //-----------------------------------------------//
        case "delthread":
            delthread();
            break;
            //-----------------------------------------------//
        //-----------------------------------------------//
        case "message":
            message();
            break;
        case "moderatemessage":
            moderatemessage();
            break;
        case "modstatusthread":
            modstatusthread();
            break;
        case "changeerased":
            changeerase();
            break;
            //-----------------------------------------------//
        //-----------------------------------------------//
        case "addmessage":
            addmessage();
            break;
        case "insmessage":
            insmessage();
            break;
            //-----------------------------------------------//
        //-----------------------------------------------//
        case "modmessage":
            modmessage();
            break;
        case "upmessage":
            upmessage();
            break;
            //-----------------------------------------------//
        //-----------------------------------------------//
        case "delmessage":
            delmessage();
            break;
            //-----------------------------------------------//
        //-----------------------------------------------//
        case "viewprofile":
            viewprofile();
            break;
            //-----------------------------------------------//
        //-----------------------------------------------//
        case "editsema":
            editsema();
            break;
        case "savesema":
            savesema();
            break;
            //-----------------------------------------------//
        //-----------------------------------------------//
        case "download":
            checkPerm('view');
            require_once _base_ . '/lib/lib.download.php';
            //find file
            list($title, $attach) = sql_fetch_row(sql_query("\r\n\t\t\tSELECT title, attach\r\n\t\t\tFROM " . $GLOBALS['prefix_lms'] . "_forummessage\r\n\t\t\tWHERE idMessage='" . (int) $_GET['id'] . "'"));
            if (!$attach) {
                $GLOBALS['page']->add(getErrorUi('Sorry, such file does not exist!'), 'content');
                return;
            }
            //recognize mime type
            $expFileName = explode('.', $attach);
            $totPart = count($expFileName) - 1;
            $path = '/appLms/' . Get::sett('pathforum');
            //send file
            sendFile($path, $attach, $expFileName[$totPart]);
            break;
            //-----------------------------------------------//
        //-----------------------------------------------//
        case "search":
            forumsearch();
            break;
        case "searchmessage":
            forumsearchmessage();
            break;
            //-----------------------------------------------//
    }
}
开发者ID:abhinay100,项目名称:forma_app,代码行数:101,代码来源:forum.php

示例11: mediaFN

    }
    $FILE = mediaFN($MEDIA);
}
//check file existance
if (!@file_exists($FILE)) {
    header("HTTP/1.0 404 Not Found");
    //FIXME add some default broken image
    print 'Not Found';
    exit;
}
//handle image resizing
if (substr($MIME, 0, 5) == 'image' && $WIDTH) {
    $FILE = get_resized($FILE, $EXT, $WIDTH, $HEIGHT);
}
// finally send the file to the client
sendFile($FILE, $MIME, $CACHE);
/* ------------------------------------------------------------------------ */
/**
 * Set headers and send the file to the client
 *
 * @author Andreas Gohr <andi@splitbrain.org>
 * @author Ben Coburn <btcoburn@silicodon.net>
 */
function sendFile($file, $mime, $cache)
{
    global $conf;
    $fmtime = filemtime($file);
    // send headers
    header("Content-Type: {$mime}");
    // smart http caching headers
    if ($cache == -1) {
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:31,代码来源:fetch.php

示例12: moveFolder

     moveFolder();
     break;
 case 'deletefolder':
     deleteFolder();
     break;
 case 'sharefolder':
     shareFolder();
     break;
 case 'unsharefolder':
     unshareFolder();
     break;
 case 'getshareinfo':
     getShareInfo();
     break;
 case 'sendfile':
     sendFile();
     break;
 case 'filerevisions':
     getFileRevisions();
     break;
 case 'storagerevisions':
     getStorageRevisions();
     break;
 case 'downloadafile':
     $t = true;
     $err = '';
     if (strlen($_POST['token']) == 0) {
         $t = false;
         $err = 1;
     }
     if (strlen($_POST['durl']) == 0) {
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:31,代码来源:StoreMethods.php

示例13: specialop

 /**
  * use only for special operation
  *
  * @access public
  */
 function specialop()
 {
     require_once _base_ . '/lib/lib.download.php';
     $re_entry = sql_query("\r\n\t\tSELECT user_entry\r\n\t\tFROM " . $this->_getUserEntryTable() . "\r\n\t\tWHERE id_user = '" . importVar('id_user', true) . "' AND\r\n\t\t\tid_common = '" . (int) $this->id_common . "' AND\r\n\t\t\tid_common_son = '0'");
     list($file) = sql_fetch_row($re_entry);
     $path = $GLOBALS['where_files_relative'] . '/appCore/field/';
     sendFile($path, $file);
 }
开发者ID:abhinay100,项目名称:forma_app,代码行数:13,代码来源:class.upload.php

示例14: Copyright

  @comment   
  @copyright Copyright (c) 2011-2012 Plugin Monitoring for GLPI team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://forge.indepnet.net/projects/monitoring/
  @since     2011

  ------------------------------------------------------------------------
*/
if (!defined('GLPI_ROOT')) {
    define('GLPI_ROOT', '../../..');
}
include GLPI_ROOT . "/inc/includes.php";
checkLoginUser();
$docDir = GLPI_PLUGIN_DOC_DIR . '/monitoring';
if (isset($_GET['file'])) {
    $filename = $_GET['file'];
    $file = $docDir . '/' . $filename;
    if (preg_match("/PluginMonitoringService-([0-9]+)-2h([0-9]+).png/", $filename)) {
        include GLPI_ROOT . "/inc/includes.php";
        $match = array();
        preg_match("/PluginMonitoringService-([0-9]+)-2h([0-9]+).png/", $filename, $match);
        $pmServicegraph = new PluginMonitoringServicegraph();
        $pmService = new PluginMonitoringService();
        $pmComponent = new PluginMonitoringComponent();
        $pmService->getFromDB($match[1]);
        $pmComponent->getFromDB($pmService->fields['plugin_monitoring_components_id']);
        $pmServicegraph->displayGraph($pmComponent->fields['graph_template'], "PluginMonitoringService", $match[1], $match[2], '2h');
    }
    sendFile($file, $filename);
}
开发者ID:RubichonL,项目名称:glpi_monitoring,代码行数:31,代码来源:send.php

示例15: catch

try {
    $res = $search->search("emultimedia", $columns, $terms);
} catch (Exception $e) {
    //echo $e;
    sendError(406);
}
if (isset($res->rows[0]["resource"])) {
    $media = $res->rows[0]["resource"];
} else {
    sendError(404);
}
$temp_file = tempnam(sys_get_temp_dir(), 'IMU');
saveFile($temp_file, $media);
$fn = $media["identifier"];
$mime = $media["mimeType"] . "/" . $media["mimeFormat"];
sendFile($temp_file, $mime, $fn);
function saveFile($newloc, $file)
{
    // Save a copy of the resource
    $temp = $file['file'];
    $copy = fopen($newloc, 'wb');
    for (;;) {
        $data = fread($temp, 4096);
        // read 4K at a time
        if ($data === false || strlen($data) == 0) {
            break;
        }
        fwrite($copy, $data);
    }
    fclose($copy);
}
开发者ID:CMP-Studio,项目名称:IMuAPI,代码行数:31,代码来源:index.php


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