Upload and download php files

Source: Internet
Author: User
Tags date end file upload getdate string string format strlen touch

File upload 1, client settings: (1), in the label Enctype and method two properties indicate the corresponding value. &NB [...]

First, the file upload

1, client settings:

(1), in

Second, File download

Simple file downloads only need to use HTML link tags and specify the URL value of the attribute href to the downloaded file. This method can only handle MIME type files that are not recognized by browsers.

In order to improve security, 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.

Third, file function library

Touch

To set the access and grooming time for a file

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

Copy

Copying files

BOOL Copy (string $source, String $dest)

Note: Please use the rename function to move the file

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 other than Resouce. You can even serialize () those that contain arrays that point 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

Gets the string length

int strlen (string $str);

Strtolower

String conversion to lowercase

String Strtolower (string $str);

Strtoupper

String conversion to uppercase

String Strtoupper (string $str);

Ucfirst

Capitalize first letter

String Ucfirst (string $str);

Ucwords

Convert the first letter of each word to an uppercase letter

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 start 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 a character at the first occurrence of another character

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




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.