Home  >  Article  >  Backend Development  >  PHP Mobile Internet Development Notes (5) - File Upload and Download_PHP Tutorial

PHP Mobile Internet Development Notes (5) - File Upload and Download_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:35:13805browse

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/746359.htmlTechArticle 1. File upload 1. Client settings: (1), 2. File download Simple file download only You need to use HTML link tags and specify the URL value of the href attribute to the downloaded file...
Statement:
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