Personal Blog Original: http://www.phpthinking.com/archives/332
One, the file upload 1, the client settings: (1), in the label will be Enctype and method two properties to indicate the corresponding value. &NB [...]
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]);
Upload and download php files