PHP Mobile Internet Development Notes (5)--Upload and download files

Source: Internet
Author: User
Tags md5 hash rtrim

Original address: http://www.php100.com/html/php/rumen/2014/0326/6706.html


First, the file upload

1. Client settings:

(1), in

Second, the file download

Simple file download only needs to use the HTML link tag, and specify the URL value of the attribute href to the downloaded file. This method only handles MIME type files that are not recognized by browsers.




In order to improve security and do not want the file link in the A tag, you must send the necessary header information to the browser, we can use the following code.

Third, the File function library

Touch

Set access and adornment time for files

BOOL Touch (string $filename [, int $time [, int $time]]

Copy

Copying files

BOOL Copy (string $source, String $dest)

Note: To move a file, use the Rename function

File_put_contents

Writes 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 of

String serialize (mixed $value)

Note: Serialize () can handle any type except Resouce. You can even serialize () those arrays that contain pointers to their own references.

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 number of microseconds

Mixed Microtime ([bool get_as_float]);

Date_default_timezone_set

Set the default time zone

BOOL Date_default_timezone_set (string timezone_identifier);

Date_default_timezone_get

Get the default time zone

String date_default_timezone_get (void);

Three, character function library

Strlen

Get string length

int strlen (string $str);

Strtolower

String converted to lowercase

String Strtolower (string $str);

Strtoupper

Convert string to uppercase

String Strtoupper (string $str);

Ucfirst

Capitalize 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 a string

String LTrim (String $str [, String $charlist]);

RTrim

Remove spaces or other characters from the end of a string

String RTrim (String $str [, String $chirlist]);

Trim

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

Str_replace

Character substitution

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

Str_ireplace

Character substitution

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

MD5

Computes the MD5 hash of a string

String MD5 (string $str [, bool $raw _output=false]);

Strpos

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

int Strpos (String haystack, mixed needle[, int offset]);


PHP Mobile Internet Development Notes (5)--Upload and download files

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.