direktori cari
Array Array Helper Benchmarking Benchmarking Class Caching Caching Driver Calendaring Calendaring Class CAPTCHA CAPTCHA Helper Config Config Class Cookie Cookie Helper Database Connecting to your Database Custom Function Calls Database Caching Class Database Configuration Database Forge Class Database Metadata Database Quick Start: Example Code Database Reference Database Utility Class DB Driver Reference Generating Query Results Queries Query Builder Class Query Helper Methods Transactions Date Date Helper Directory Directory Helper Download Download Helper Email Email Class Email Helper Encrypt Encrypt Class Encryption Encryption Library File File Helper File Uploading File Uploading Class Form Form Helper Form Validation Form Validation FTP FTP Class Functions compatibility_functions common_functions HTML HTML Helper HTML Table HTML Table Class Image Manipulation Image Manipulation Class Inflector Inflector Helper Input Input Class Javascript Javascript Class Language Language Class Language Helper Loader Loader Class Migrations Migrations Class Number Number Helper Output Output Class Pagination Pagination Class Path Path Helper Security Security Class Security Helper Session Session Library Shopping Cart Shopping Cart Class Smiley Smiley Helper String String Helper Template Parser Template Parser Class Text Text Helper Trackback Trackback Class Typography Typography Class Typography Helper Unit Testing Unit Testing Class URI URL User Agent XML XML-RPC and XML-RPC Server Zip Encoding Zip Encoding Class XML-RPC and XML-RPC Server Classes XML Helper User Agent Class URL Helper URI Class
watak

下载帮助程序允许您将数据下载到桌面上。

  • 加载此助手

  • 可用职能

加载此助手

使用以下代码加载此助手:

$this->load->helper('download');

可用职能

现有下列职能:

force_download([$filename = ''[, $data = ''[, $set_mime = FALSE]]])

参数:

$ filename(string) - 文件名$ data(mixed) - 文件内容$ set_mime(bool) - 是否尝试发送实际的MIME类型

返回类型:

空虚

  • $ filename字符串) - 文件名

  • $ data混合) - 文件内容

  • $ set_mimebool) - 是否尝试发送实际的MIME类型

Return type:  void
Generates server headers which force data to be downloaded to your desktop. Useful with file downloads. The first parameter is the **name you want the downloaded file to be named**, the second parameter is the file data.

如果将第二个参数设置为NULL和$filename是一个现有的、可读的文件路径,那么它的内容将被读取。

如果您将第三个参数设置为布尔值true,那么将发送基于文件扩展名%29的实际文件MIME类型%28,这样如果浏览器有该类型的处理程序,它就可以使用它。

例子:

$ data ='这是一些文字!'; $ name ='mytext.txt'; force_download($ name,$ data);

如果要从服务器下载现有文件,则需要执行以下操作:

// photo.jpg的内容将被自动读取force_download('/ path / to / photo.jpg',NULL);

Artikel sebelumnya: Artikel seterusnya: