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


PHP send_file函数代码示例

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


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

示例1: close

 /**
  * Close the Moodle Workbook.
  */
 public function close()
 {
     global $CFG;
     require_once $CFG->libdir . '/filelib.php';
     $writer = new MoodleODSWriter($this->worksheets);
     $contents = $writer->get_file_content();
     send_file($contents, $this->filename, 0, 0, true, true, $writer->get_ods_mimetype());
 }
开发者ID:evltuma,项目名称:moodle,代码行数:11,代码来源:odslib.class.php

示例2: send_export_xml

 /**
  * Send role export xml file to browser.
  *
  * @param int $roleid
  * @return void does not return, send the file to output
  */
 public static function send_export_xml($roleid)
 {
     global $CFG, $DB;
     require_once $CFG->libdir . '/filelib.php';
     $role = $DB->get_record('role', array('id' => $roleid), '*', MUST_EXIST);
     if ($role->shortname) {
         $filename = $role->shortname . '.xml';
     } else {
         $filename = 'role.xml';
     }
     $xml = self::get_export_xml($roleid);
     send_file($xml, $filename, 0, false, true, true);
     die;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:20,代码来源:preset.php

示例3: get_thumb

function get_thumb($C)
{
    $C = basename($C);
    $G = IDIR . $C;
    $H = null;
    if (_CACHE) {
        $H = CDIR . $C;
        if (file_exists($H)) {
            send_file($H, 'image/jpeg');
            return;
        }
    }
    list($A, $B) = getimagesize($G);
    if ($A > $B) {
        $T = round(($A - $B) / 2);
        $R = 0;
        $A = $B;
    } else {
        $T = 0;
        $R = round(($B - $A) / 2);
        $B = $A;
    }
    $K = imagecreatetruecolor(TS, TS);
    imageinterlace($K, true);
    $Q = @imagecreatefromstring(file_get_contents($G));
    if (!$Q) {
        header("HTTP/1.0 400 Image unreadable, unsupported type.");
        exit;
    }
    imagecopyresampled($K, $Q, 0, 0, $T, $R, TS, TS, $A, $B);
    if (_CACHE) {
        imagejpeg($K, $H, QUALITY);
        send_file($H, 'image/jpeg');
    } else {
        header('Content-Type: image/jpeg');
        imagejpeg($K, null, QUALITY);
    }
    imagedestroy($K);
    imagedestroy($Q);
}
开发者ID:fbianco,项目名称:MimingGallery,代码行数:40,代码来源:index.php

示例4: book_pluginfile

/**
 * Serves the book attachments. Implements needed access control ;-)
 *
 * @param stdClass $course course object
 * @param cm_info $cm course module object
 * @param context $context context object
 * @param string $filearea file area
 * @param array $args extra arguments
 * @param bool $forcedownload whether or not force download
 * @param array $options additional options affecting the file serving
 * @return bool false if file not found, does not return if found - just send the file
 */
function book_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array())
{
    global $CFG, $DB;
    if ($context->contextlevel != CONTEXT_MODULE) {
        return false;
    }
    require_course_login($course, true, $cm);
    if ($filearea !== 'chapter') {
        return false;
    }
    if (!has_capability('mod/book:read', $context)) {
        return false;
    }
    $chid = (int) array_shift($args);
    if (!($book = $DB->get_record('book', array('id' => $cm->instance)))) {
        return false;
    }
    if (!($chapter = $DB->get_record('book_chapters', array('id' => $chid, 'bookid' => $book->id)))) {
        return false;
    }
    if ($chapter->hidden and !has_capability('mod/book:viewhiddenchapters', $context)) {
        return false;
    }
    // Download the contents of a chapter as an html file.
    if ($args[0] == 'index.html') {
        $filename = "index.html";
        // We need to rewrite the pluginfile URLs so the media filters can work.
        $content = file_rewrite_pluginfile_urls($chapter->content, 'webservice/pluginfile.php', $context->id, 'mod_book', 'chapter', $chapter->id);
        $formatoptions = new stdClass();
        $formatoptions->noclean = true;
        $formatoptions->overflowdiv = true;
        $formatoptions->context = $context;
        $content = format_text($content, $chapter->contentformat, $formatoptions);
        // Remove @@PLUGINFILE@@/.
        $options = array('reverse' => true);
        $content = file_rewrite_pluginfile_urls($content, 'webservice/pluginfile.php', $context->id, 'mod_book', 'chapter', $chapter->id, $options);
        $content = str_replace('@@PLUGINFILE@@/', '', $content);
        $titles = "";
        // Format the chapter titles.
        if (!$book->customtitles) {
            require_once __DIR__ . '/locallib.php';
            $chapters = book_preload_chapters($book);
            if (!$chapter->subchapter) {
                $currtitle = book_get_chapter_title($chapter->id, $chapters, $book, $context);
                // Note that we can't use the $OUTPUT->heading() in WS_SERVER mode.
                $titles = "<h3>{$currtitle}</h3>";
            } else {
                $currtitle = book_get_chapter_title($chapters[$chapter->id]->parent, $chapters, $book, $context);
                $currsubtitle = book_get_chapter_title($chapter->id, $chapters, $book, $context);
                // Note that we can't use the $OUTPUT->heading() in WS_SERVER mode.
                $titles = "<h3>{$currtitle}</h3>";
                $titles .= "<h4>{$currsubtitle}</h4>";
            }
        }
        $content = $titles . $content;
        send_file($content, $filename, 0, 0, true, true);
    } else {
        $fs = get_file_storage();
        $relativepath = implode('/', $args);
        $fullpath = "/{$context->id}/mod_book/chapter/{$chid}/{$relativepath}";
        if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
            return false;
        }
        // Nasty hack because we do not have file revisions in book yet.
        $lifetime = $CFG->filelifetime;
        if ($lifetime > 60 * 10) {
            $lifetime = 60 * 10;
        }
        // Finally send the file.
        send_stored_file($file, $lifetime, 0, $forcedownload, $options);
    }
}
开发者ID:evltuma,项目名称:moodle,代码行数:84,代码来源:lib.php

示例5: question_pluginfile

/**
 * Called by pluginfile.php to serve files related to the 'question' core
 * component and for files belonging to qtypes.
 *
 * For files that relate to questions in a question_attempt, then we delegate to
 * a function in the component that owns the attempt (for example in the quiz,
 * or in core question preview) to get necessary inforation.
 *
 * (Note that, at the moment, all question file areas relate to questions in
 * attempts, so the If at the start of the last paragraph is always true.)
 *
 * Does not return, either calls send_file_not_found(); or serves the file.
 *
 * @param object $course course settings object
 * @param object $context context object
 * @param string $component the name of the component we are serving files for.
 * @param string $filearea the name of the file area.
 * @param array $args the remaining bits of the file path.
 * @param bool $forcedownload whether the user must be forced to download the file.
 */
function question_pluginfile($course, $context, $component, $filearea, $args, $forcedownload)
{
    global $DB, $CFG;
    list($context, $course, $cm) = get_context_info_array($context->id);
    require_login($course, false, $cm);
    if ($filearea === 'export') {
        require_once $CFG->dirroot . '/question/editlib.php';
        $contexts = new question_edit_contexts($context);
        // check export capability
        $contexts->require_one_edit_tab_cap('export');
        $category_id = (int) array_shift($args);
        $format = array_shift($args);
        $cattofile = array_shift($args);
        $contexttofile = array_shift($args);
        $filename = array_shift($args);
        // load parent class for import/export
        require_once $CFG->dirroot . '/question/format.php';
        require_once $CFG->dirroot . '/question/editlib.php';
        require_once $CFG->dirroot . '/question/format/' . $format . '/format.php';
        $classname = 'qformat_' . $format;
        if (!class_exists($classname)) {
            send_file_not_found();
        }
        $qformat = new $classname();
        if (!($category = $DB->get_record('question_categories', array('id' => $category_id)))) {
            send_file_not_found();
        }
        $qformat->setCategory($category);
        $qformat->setContexts($contexts->having_one_edit_tab_cap('export'));
        $qformat->setCourse($course);
        if ($cattofile == 'withcategories') {
            $qformat->setCattofile(true);
        } else {
            $qformat->setCattofile(false);
        }
        if ($contexttofile == 'withcontexts') {
            $qformat->setContexttofile(true);
        } else {
            $qformat->setContexttofile(false);
        }
        if (!$qformat->exportpreprocess()) {
            send_file_not_found();
            print_error('exporterror', 'question', $thispageurl->out());
        }
        // export data to moodle file pool
        if (!($content = $qformat->exportprocess(true))) {
            send_file_not_found();
        }
        //DEBUG
        //echo '<textarea cols=90 rows=20>';
        //echo $content;
        //echo '</textarea>';
        //die;
        send_file($content, $filename, 0, 0, true, true, $qformat->mime_type());
    }
    $attemptid = (int) array_shift($args);
    $questionid = (int) array_shift($args);
    if ($attemptid === 0) {
        // preview
        require_once $CFG->dirroot . '/question/previewlib.php';
        return question_preview_question_pluginfile($course, $context, $component, $filearea, $attemptid, $questionid, $args, $forcedownload);
    } else {
        $module = $DB->get_field('question_attempts', 'modulename', array('id' => $attemptid));
        $dir = get_component_directory($module);
        if (!file_exists("{$dir}/lib.php")) {
            send_file_not_found();
        }
        include_once "{$dir}/lib.php";
        $filefunction = $module . '_question_pluginfile';
        if (!function_exists($filefunction)) {
            send_file_not_found();
        }
        $filefunction($course, $context, $component, $filearea, $attemptid, $questionid, $args, $forcedownload);
        send_file_not_found();
    }
}
开发者ID:vuchannguyen,项目名称:web,代码行数:96,代码来源:questionlib.php

示例6: send_thumbnail

 /**
  * Displays a thumbnail for current user's dropbox file
  *
  * @param string $string
  */
 public function send_thumbnail($source)
 {
     global $CFG;
     $saveas = $this->prepare_file('');
     try {
         $access_key = get_user_preferences($this->setting . '_access_key', '');
         $access_secret = get_user_preferences($this->setting . '_access_secret', '');
         $this->dropbox->set_access_token($access_key, $access_secret);
         $this->dropbox->get_thumbnail($source, $saveas, $CFG->repositorysyncimagetimeout);
         $content = file_get_contents($saveas);
         unlink($saveas);
         // set 30 days lifetime for the image. If the image is changed in dropbox it will have
         // different revision number and URL will be different. It is completely safe
         // to cache thumbnail in the browser for a long time
         send_file($content, basename($source), 30 * 24 * 60 * 60, 0, true);
     } catch (Exception $e) {
     }
 }
开发者ID:krysnuvadga,项目名称:moodle,代码行数:23,代码来源:lib.php

示例7: send_relative_file

 /**
  *  Gets a file relative to this file in the repository and sends it to the browser.
  *
  * @param stored_file $mainfile The main file we are trying to access relative files for.
  * @param string $relativepath the relative path to the file we are trying to access.
  */
 public function send_relative_file(stored_file $mainfile, $relativepath)
 {
     global $CFG;
     // Check if this repository is allowed to use relative linking.
     $allowlinks = $this->supports_relative_file();
     if (!empty($allowlinks)) {
         // Get path to the mainfile.
         $mainfilepath = $mainfile->get_source();
         // Strip out filename from the path.
         $filename = $mainfile->get_filename();
         $basepath = strstr($mainfilepath, $filename, true);
         $fullrelativefilepath = realpath($this->get_rootpath() . $basepath . $relativepath);
         // Sanity check to make sure this path is inside this repository and the file exists.
         if (strpos($fullrelativefilepath, realpath($this->get_rootpath())) === 0 && file_exists($fullrelativefilepath)) {
             send_file($fullrelativefilepath, basename($relativepath), null, 0);
         }
     }
     send_file_not_found();
 }
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:25,代码来源:lib.php

示例8: file_pluginfile

/**
 * This function delegates file serving to individual plugins
 *
 * @param string $relativepath
 * @param bool $forcedownload
 * @param null|string $preview the preview mode, defaults to serving the original file
 * @todo MDL-31088 file serving improments
 */
function file_pluginfile($relativepath, $forcedownload, $preview = null)
{
    global $DB, $CFG, $USER;
    // relative path must start with '/'
    if (!$relativepath) {
        print_error('invalidargorconf');
    } else {
        if ($relativepath[0] != '/') {
            print_error('pathdoesnotstartslash');
        }
    }
    // extract relative path components
    $args = explode('/', ltrim($relativepath, '/'));
    if (count($args) < 3) {
        // always at least context, component and filearea
        print_error('invalidarguments');
    }
    $contextid = (int) array_shift($args);
    $component = clean_param(array_shift($args), PARAM_COMPONENT);
    $filearea = clean_param(array_shift($args), PARAM_AREA);
    list($context, $course, $cm) = get_context_info_array($contextid);
    $fs = get_file_storage();
    // ========================================================================================================================
    if ($component === 'blog') {
        // Blog file serving
        if ($context->contextlevel != CONTEXT_SYSTEM) {
            send_file_not_found();
        }
        if ($filearea !== 'attachment' and $filearea !== 'post') {
            send_file_not_found();
        }
        if (empty($CFG->enableblogs)) {
            print_error('siteblogdisable', 'blog');
        }
        $entryid = (int) array_shift($args);
        if (!($entry = $DB->get_record('post', array('module' => 'blog', 'id' => $entryid)))) {
            send_file_not_found();
        }
        if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL) {
            require_login();
            if (isguestuser()) {
                print_error('noguest');
            }
            if ($CFG->bloglevel == BLOG_USER_LEVEL) {
                if ($USER->id != $entry->userid) {
                    send_file_not_found();
                }
            }
        }
        if ($entry->publishstate === 'public') {
            if ($CFG->forcelogin) {
                require_login();
            }
        } else {
            if ($entry->publishstate === 'site') {
                require_login();
                //ok
            } else {
                if ($entry->publishstate === 'draft') {
                    require_login();
                    if ($USER->id != $entry->userid) {
                        send_file_not_found();
                    }
                }
            }
        }
        $filename = array_pop($args);
        $filepath = $args ? '/' . implode('/', $args) . '/' : '/';
        if (!($file = $fs->get_file($context->id, $component, $filearea, $entryid, $filepath, $filename)) or $file->is_directory()) {
            send_file_not_found();
        }
        send_stored_file($file, 10 * 60, 0, true, array('preview' => $preview));
        // download MUST be forced - security!
        // ========================================================================================================================
    } else {
        if ($component === 'grade') {
            if (($filearea === 'outcome' or $filearea === 'scale') and $context->contextlevel == CONTEXT_SYSTEM) {
                // Global gradebook files
                if ($CFG->forcelogin) {
                    require_login();
                }
                $fullpath = "/{$context->id}/{$component}/{$filearea}/" . implode('/', $args);
                if (!($file = $fs->get_file_by_hash(sha1($fullpath))) or $file->is_directory()) {
                    send_file_not_found();
                }
                \core\session\manager::write_close();
                // Unlock session during file serving.
                send_stored_file($file, 60 * 60, 0, $forcedownload, array('preview' => $preview));
            } else {
                if ($filearea === 'feedback' and $context->contextlevel == CONTEXT_COURSE) {
                    //TODO: nobody implemented this yet in grade edit form!!
                    send_file_not_found();
//.........这里部分代码省略.........
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:101,代码来源:filelib.php

示例9: array_shift

    // force download of all attachments
}
// security: some protection of hidden resource files
// warning: it may break backwards compatibility
if (!empty($CFG->preventaccesstohiddenfiles) and count($args) >= 2 and !(strtolower($args[1]) == 'moddata' and strtolower($args[2]) != 'resource') and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
    $rargs = $args;
    array_shift($rargs);
    $reference = implode('/', $rargs);
    $sql = "SELECT COUNT(r.id) " . "FROM {$CFG->prefix}resource r, " . "{$CFG->prefix}course_modules cm, " . "{$CFG->prefix}modules m " . "WHERE r.course    = '{$course->id}' " . "AND m.name      = 'resource' " . "AND cm.module   = m.id " . "AND cm.instance = r.id " . "AND cm.visible  = 0 " . "AND r.type      = 'file' " . "AND r.reference = '{$reference}'";
    if (count_records_sql($sql)) {
        error('Access not allowed');
    }
}
// check that file exists
if (!file_exists($pathname)) {
    not_found($course->id);
}
// ========================================
// finally send the file
// ========================================
session_write_close();
// unlock session during fileserving
$filename = $args[count($args) - 1];
send_file($pathname, $filename, $lifetime, $CFG->filteruploadedfiles, false, $forcedownload);
function not_found($courseid)
{
    global $CFG;
    header('HTTP/1.0 404 not found');
    print_error('filenotfound', 'error', $CFG->wwwroot . '/course/view.php?id=' . $courseid);
    //this is not displayed on IIS??
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:file.php

示例10: required_param

<?php

/*
 * This file is called by the offline Moodle SERVER and sends the existing
 * incremental or Full backup if no incremental is available to the client.
 * 
 */
require '../config.php';
require_once "{$CFG->dirroot}/backup/backup_sch_incremental.php";
require_once "{$CFG->dirroot}/backup/incremental_backuplib.php";
require_once "{$CFG->dirroot}/backup/backuplib.php";
require_once "{$CFG->dirroot}/backup/lib.php";
require_once "{$CFG->dirroot}/lib/filelib.php";
$currenthash = required_param('hash');
// hash
$action = required_param('action');
// what to do?
$file = get_incremental($currenthash);
if ($file) {
    if ($action == 'curldownload') {
        readfile_chunked($file->path . $file->name);
    } elseif ($action == 'download') {
        send_file($file->path, $file->name, 864, 0, true, true);
    } elseif ($action == 'check') {
        echo $file->name;
    } else {
        echo 'no action specified';
    }
} else {
    echo 'ERROR!!! No file returned';
}
开发者ID:r007,项目名称:PMoodle,代码行数:31,代码来源:send_incremental.php

示例11: rss_error

/**
 * Sends an error formatted as an rss file and then exits
 *
 * @package core_rss
 * @category rss
 *
 * @param string $error the error type, default is rsserror
 * @param string $filename the name of the file to create (NOT USED)
 * @param int $lifetime UNSURE (NOT USED)
 * @uses exit
 */
function rss_error($error = 'rsserror', $filename = 'rss.xml', $lifetime = 0)
{
    send_file(rss_geterrorxmlfile($error), $filename, $lifetime, false, true);
    exit;
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:16,代码来源:file.php

示例12: send_file

 /**
  * Repository method to serve the referenced file
  *
  * @see send_stored_file
  *
  * @param stored_file $storedfile the file that contains the reference
  * @param int $lifetime Number of seconds before the file should expire from caches (default 24 hours)
  * @param int $filter 0 (default)=no filtering, 1=all files, 2=html files only
  * @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin
  * @param array $options additional options affecting the file serving
  */
 public function send_file($storedfile, $lifetime=86400 , $filter=0, $forcedownload=false, array $options = null) {
     $reference = $storedfile->get_reference();
     if ($reference{0} == '/') {
         $file = $this->root_path.substr($reference, 1, strlen($reference)-1);
     } else {
         $file = $this->root_path.$reference;
     }
     if (is_readable($file)) {
         $filename = $storedfile->get_filename();
         if ($options && isset($options['filename'])) {
             $filename = $options['filename'];
         }
         $dontdie = ($options && isset($options['dontdie']));
         send_file($file, $filename, $lifetime , $filter, false, $forcedownload, '', $dontdie);
     } else {
         send_file_not_found();
     }
 }
开发者ID:nigeli,项目名称:moodle,代码行数:29,代码来源:lib.php

示例13: tex2image

function tex2image($texexp, $md5, $return = false)
{
    global $CFG;
    if (!$texexp) {
        echo 'No tex expresion specified';
        return;
    }
    $texexp = '\\Large ' . $texexp;
    $image = $md5 . ".gif";
    $filetype = 'image/gif';
    if (!file_exists("{$CFG->dataroot}/filter/algebra")) {
        make_upload_directory("filter/algebra");
    }
    $pathname = "{$CFG->dataroot}/filter/algebra/{$image}";
    if (file_exists($pathname)) {
        unlink($pathname);
    }
    $commandpath = filter_tex_get_executable(true);
    $cmd = filter_tex_get_cmd($pathname, $texexp);
    system($cmd, $status);
    if ($return) {
        return $image;
    }
    if (file_exists($pathname)) {
        send_file($pathname, $image);
    } else {
        $ecmd = "{$cmd} 2>&1";
        echo `{$ecmd}` . "<br />\n";
        echo "The shell command<br />{$cmd}<br />returned status = {$status}<br />\n";
        if ($status == 4) {
            echo "Status corresponds to illegal instruction<br />\n";
        } else {
            if ($status == 11) {
                echo "Status corresponds to bus error<br />\n";
            } else {
                if ($status == 22) {
                    echo "Status corresponds to abnormal termination<br />\n";
                }
            }
        }
        if (file_exists($commandpath)) {
            echo "File size of mimetex executable  {$commandpath} is " . filesize($commandpath) . "<br />";
            echo "The file permissions are: " . decoct(fileperms($commandpath)) . "<br />";
            if (function_exists("md5_file")) {
                echo "The md5 checksum of the file is " . md5_file($commandpath) . "<br />";
            } else {
                $handle = fopen($commandpath, "rb");
                $contents = fread($handle, 16384);
                fclose($handle);
                echo "The md5 checksum of the first 16384 bytes is " . md5($contents) . "<br />";
            }
        } else {
            echo "mimetex executable {$commandpath} not found!<br />";
        }
        echo "Image not found!";
    }
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:57,代码来源:algebradebug.php

示例14: html_entity_decode

        $background = $CFG->filter_tex_latexbackground;
        $texexp = html_entity_decode($texcache->rawtext);
        $latex_path = $latex->render($texexp, $md5, 12, $density, $background);
        if ($latex_path) {
            copy($latex_path, $pathname);
            $latex->clean_up($md5);
        } else {
            // failing that, use mimetex
            $texexp = $texcache->rawtext;
            $texexp = str_replace('&lt;', '<', $texexp);
            $texexp = str_replace('&gt;', '>', $texexp);
            $texexp = preg_replace('!\\r\\n?!', ' ', $texexp);
            $texexp = '\\Large ' . $texexp;
            $cmd = tex_filter_get_cmd($pathname, $texexp);
            system($cmd, $status);
        }
    }
}
if (file_exists($pathname)) {
    send_file($pathname, $image);
} else {
    if (debugging()) {
        echo "The shell command<br />{$cmd}<br />returned status = {$status}<br />\n";
        echo "Image not found!<br />";
        echo "Please try the <a href=\"{$CFG->wwwroot}/filter/tex/texdebug.php\">debugging script</a>";
    } else {
        echo "Image not found!<br />";
        echo "Please try the <a href=\"{$CFG->wwwroot}/filter/tex/texdebug.php\">debugging script</a><br />";
        echo "Please turn on debug mode in site configuration to see more info here.";
    }
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:pix.php

示例15: KLogger

require_once 'KLogger.php';
$log = new KLogger("log.txt", KLogger::DEBUG);
if (empty($_GET['fileid'])) {
    return false;
} else {
    $fileid = $_GET['fileid'];
}
$log->LogInfo("Download: {$fileid}");
// log file
$client_no = rand();
$logfile = uniqid(rand(), true) . '.log';
$outfile = uniqid(rand(), true) . '.out';
system("cd ../bin; ./CLIENT_p -i {$client_no} -a download -f {$fileid} -t {$outfile} > {$logfile} 2>&1");
$log->LogInfo("Downloaded from NCDS FileID: {$fileid}");
send_file("../bin/{$outfile}", $fileid);
unlink("../bin/{$outfile}");
unlink("../bin/{$logfile}");
$log->LogInfo("Sent to Client FileID: {$fileid}");
function send_file($file, $fileid)
{
    if (empty($_GET['filename'])) {
        $filename = $fileid;
    } else {
        $filename = urldecode($_GET['filename']);
    }
    if (file_exists($file)) {
        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header("Content-Disposition: attachment; filename={$filename}");
        header('Content-Transfer-Encoding: binary');
开发者ID:chen--oRanGe,项目名称:codfs,代码行数:30,代码来源:do_download.php


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