Mobile Web Development tutorial Five, PHP upload download file

Source: Internet
Author: User
Tags file upload md5 md5 hash php script rtrim serialization strlen touch

First, the file upload

1, client settings:

(1), in

Label Enctype and method two properties to indicate the corresponding values.

Enctype= "Multipart/form-data"; Method= "POST"

(2), form form to set up a hidden type of input box, where the value of name is max_file_size hidden value

2, server-side settings:

(1), $_files Multidimensional array: Used to store all kinds of uploaded files related to Information

(2), File Upload and PHP configuration file settings, such as the following php.ini files in some instructions

Instruction default Function description

File_uploads on determines whether the PHP script on the server can accept HTTP file uploads

Memory_limit 8M Sets the maximum amount of memory the script can allocate to prevent runaway script exclusive server Ram

Upload_max_file 2M limits the maximum size of PHP processing uploaded files, this value must be less than Post_max_size value

Post_max_size 8M limits the maximum value of information that can be accepted by post method

Upload_tmp_dir NULL upload file temporary path, can be an absolute path

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)

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

Convert string to lowercase

String Strtolower (string $str);

Strtoupper

Convert string to uppercase

String Strtoupper (string $str);

Ucfirst

Capitalize first letter

String Ucfirst (string $str);

Ucwords

Converts the first letter of each word to uppercase letters

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]);

Related Article

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.