PHP mobile internet development notes (5) -- File upload/download _ PHP Tutorial

Source: Internet
Author: User
Tags md5 hash
PHP mobile internet development notes (5)-upload and download files. I. file upload 1. client settings: (1) in Ii. download a simple file by using the HTML link, specify the URL value of the href attribute to the downloaded file. 1. upload the file.

1. client settings:

(1) in

II. file download

To download a simple file, you only need to mark the HTML link and specify the URL value of the href attribute to the downloaded file. This method can only process MIME-type files that cannot be recognized by some browsers.




To improve security, if you do not want to provide a file link in tag a, you must send necessary header information to the browser. we can use the following code.

III. file function library

Touch

Set file access and modification time

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

Copy

Copy a file

Bool copy (string $ source, string $ dest)

Note: 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 to a string

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

IV. serialization and deserialization

Serialize

Serialization

String serialize (mixed $ value)

Note: serialize () can process any type except resouce. Even serialize () contains arrays that point to its own reference.

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 the number of 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 );

III. Character function library

Strlen

Returns the string length.

Int strlen (string $ str );

Strtolower

String to lowercase

String strtolower (string $ str );

Strtoupper

Convert string to uppercase

String strtoupper (string $ str );

Ucfirst

Uppercase letters

String ucfirst (string $ str );

Ucwords

Converts the first letter of each word to an uppercase letter.

String ucwords (string $ str );

Ltrim

Removes spaces or other characters from the start of a string.

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

Rtrim

Removes spaces or other characters from the end of a string.

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

Trim

Removes spaces or other characters from the start and end of a 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 the MD5 hash of a string

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

Strpos

Returns the position where one character appears for the first time.

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




Tip 1. client settings: (1). in step 2, you only need to use the HTML link tag to download a simple file, and specify the URL value of the href attribute to the downloaded file...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.