Upload and download PHP files_PHP tutorial

WBOY
Release: 2016-07-13 10:19:06
Original
779 people have browsed it

Upload and download of PHP files

1. File upload 1. Client settings: (1) Indicate the corresponding values ​​of the enctype and method attributes in the tag. &nb […]

1. File upload

1. Client settings:

(1), in

2. File download

To download a simple file, you only need to use the HTML link tag and specify the URL value of the href attribute to the downloaded file. This method can only handle some MIME type files that the browser cannot recognize.

In order to improve security, if you do not want to give a file link in the a tag, you must send the necessary header information to the browser. We can use the following code.

3. File function library

touch

Set file access and modification time

bool touch(string $filename[, int $time[, int $time]])

copy

Copy file

bool copy(string $source, string $dest)

Note: Please use the rename function to move files

file_put_contents

Write a string to a file

int file_put_contents(string $filename, string $data[, int $flag[, resource $content]])

file_get_contents

Read the entire file into a string

string file_get_contents(string $filename[, bool user_include_path [, resource $content[, int $offset[, int $maxlen]]]])

4. Serialization and Deserialization

serialize

Serialization

string serialize(mixed $value)

Note: serialize() can handle any type except resouce. You can even serialize() arrays that contain references to themselves.

unserialize

Deserialization

mixed unserialize(string $str)

● date

Format a local time/date

string date(string format[, int timestamp]);

● getdate

Get date/time information

array getdate([int timestamp]);

● microtime

Returns the current Unix timestamp and microseconds

mixed microtime([bool get_as_float]);

● date_default_timezone_set

Set default time zone

bool date_default_timezone_set(string timezone_identifier);

● date_default_timezone_get

Get default time zone

string date_default_timezone_get(void);

3. Character function library

strlen

Get the string length

int strlen(string $str);

strtolower

Convert string to lower case

string strtolower(string $str);

strtoupper

Convert string to uppercase

string strtoupper(string $str);

ucfirst

Capitalize the first letter

string ucfirst(string $str);

ucwords

Convert the first letter of each word to uppercase

string ucwords(string $str);

ltrim

Remove spaces or other characters from the beginning of the string

string ltrim(string $str [, string $charlist]);

rtrim

Remove spaces or other characters from the end of the string

string rtrim(string $str[, string $chirlist]);

trim

Remove spaces or other characters from the beginning and end of the string

str_replace

Character replacement

mixed str_ireplace(mixed $search, mixed $replace, mixed $subject, [int $count]);

str_ireplace

Character replacement

mixed str_ireplace(mixed $search, mixed $replace, mixed $subject, [int $count]);

md5

Calculate MD5 hash of string

string md5(string $str[, bool $raw_output=false]);

strpos

Returns the position of the first occurrence of one character in another character

int strpos(string haystack, mixed needle[, int offset]);


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/879180.htmlTechArticle Upload and download of PHP files 1. Upload of files 1. Client settings: (1), in the tag The two attributes enctype and method specify the corresponding values. nb [] 1. File upload 1. Customer...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template