首頁  >  文章  >  後端開發  >  PHP行動互聯網開發之檔案的上傳下載

PHP行動互聯網開發之檔案的上傳下載

巴扎黑
巴扎黑原創
2017-03-19 09:34:59956瀏覽

[導讀] 一、檔案的上傳1、客戶端設定:(1)、在標籤中將enctype和method兩個屬性指明對應的值。 Enctype=   "multipart form-data   "; Method=   "POST   "(2)、form表單中設定一個hidden類型的input框,其中name的值為MAX

 端設定:

(1)、在

簡單檔案下載只需要使用HTML的連結標記,並將屬性href的URL值指定下載的檔案即可。這種方法只能處理一些瀏覽器無法辨識的MIME類型檔案。


PHP行動互聯網開發之檔案的上傳下載

PHP行動互聯網開發之檔案的上傳下載PHP行動互聯網開發之檔案的上傳下載 

為了提高安全性,不希望在a標籤中給出文件鏈接,則必須向瀏覽器發送必要的頭信息,我們可以使用以下程式碼。

PHP行動互聯網開發之檔案的上傳下載 

touch

設定檔案的存取與修飾時間

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

copy

複製檔案

bool copy(string $source, string $dest)

#注意:移動檔案請使用rename函數

file_put_contents

將字串寫入檔案

int file_put_contents(string $filename, string $data[, int $flag[, resource $content]])

file_get_contents

將整個檔案讀取字串

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

 

serialize

序列化

string serialize(mixed $value)

注意:serialize()可處理除了resouce之外的任何類型。甚至可以serialize()那些包含了指向其自身引用的陣列。

unserialize

反序列化

mixed unserialize(string $str)



PHP行動互聯網開發之檔案的上傳下載

PHP行動互聯網開發之檔案的上傳下載

● date

格式化一個本地時間/日期

string date(string format[, int timestamp]);

● getdate

取得日期/時間資訊

array getdate([int timestamp]);

PHP行動互聯網開發之檔案的上傳下載

PHP行動互聯網開發之檔案的上傳下載

##● microtime

傳回目前Unix時間戳與微秒數

mixed microtime([bool get_as_float]);

● date_default_timezone_set

設定預設時區

bool date_default_timezone_set(string timezone_identifier);

● date_default_timezone_get

#取得預設時區##ate_default_timeone_defaultdault_timezone_#(default);

三、字元函數庫

strlen

取得字串長度

int strlen(string $str);

strtolower

字串轉換為小寫

string strtolower(string $str);

strtoupper

字串轉換為大寫

string strtoupper(string $str);

ucfirst

首字母大寫

string ucfirst(string $str);

ucwords

將每個單字的首字母轉換為大寫字母

string ucwords(string $str);

ltrim

#從字串開始的位置刪除空格或其他字元

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

rtrim

從字串結束的位置刪除空格或其他字元

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

#trim

從字串開始和結束的位置刪除空格或其他字元

# str_replace

字元替換

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

#str_ireplace

字元替換

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

md5

 

計算字串的MD5雜湊

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

strpos

傳回一個字元在另一個字元第一次出現的位置

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

#

● datePHP行動互聯網開發之檔案的上傳下載

格式化一個本地時間/日期######string date(string format[, int timestamp]);######● getdate### ###取得日期/時間資訊######array getdate([int timestamp]);############

PHP行動互聯網開發之檔案的上傳下載

 

● microtime

返回目前Unix時間戳與微秒數

mixed microtime( [bool get_as_float]);

##● date_default_timezone_set

設定預設時區

bool date_default_timezone_set(string timezone_identifier);

##" date_#取得預設時區

string date_default_timezone_get(void);

三、字元函數庫

strlen

# 取得字串長度

int strlen(string $str);

strtolower

#字串轉換為小寫

string strtolower(string $str);

strtoupper

字串轉換為大寫

string strtoupper(string $str);

ucfirst

首字母大寫

string ucfirst(string $str);

ucwords

將每個單字的首字母轉換為大寫字母

string ucwords(string $str);

ltrim

從字串開始的位置刪除空格或其他字元

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

rtrim

#從字串結束的位置刪除空格或其他字元

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

trim

從字串開始和結束的位置刪除空格或其他字元

str_replace

字元替換

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

str_ireplace

 

字元替換

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

md5

 

計算字串的MD5雜湊

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

strpos

傳回一個字元在另一個字元第一次出現的位置

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

#● microtime

回傳目前Unix時間戳與微秒數

mixed microtime([bool get_as_float]);

##● date_default_timezone_set

設定預設區時區區

bool date_default_timezone_set(string timezone_identifier);

# date_default_timezone_get

#取得預設時區

string date_default_timezone_get(

#取得預設時區

string date_default_timezone_get(

##取得字串長度

int strlen(string $str);

strtolower

字串轉換為小寫

##string strtolower( string $str);

strtoupper

#字串轉換為大寫

string strtoupper(string $str);

ucfirst

首字母大寫

string ucfirst(string $str);

ucwords

將每個單字的首字母轉換為大寫字母

#string ucwords( string $str);

ltrim

從字串開始的位置刪除空格或其他字元

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

rtrim

從字串結束的位置刪除空格或其他字元

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

#trim

從字串開始和結束的位置刪除空格或其他字元

str_replace

字元取代

mixed str_ireplace(mixed $search, mixed $replace 、 mixed $subject, [int $count]);

str_ireplace

 

字元替換

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

md5

計算字串的MD5雜湊

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

strpos

#傳回一個字元在另一個字元第一次出現的位置

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

一、檔案的上傳

1、用戶端設定:

 

 

(1)、在

二、檔案下載

 

簡單檔案下載只需使用HTML的連結標記,並將屬性href的URL值指定下載的檔案即可。這種方法只能處理一些瀏覽器無法辨識的MIME類型檔案。

#


PHP行動互聯網開發之檔案的上傳下載 

為了提高安全性,不希望在a標籤中給出文件鏈接,則必須向瀏覽器發送必要的頭信息,我們可以使用如下代碼。

PHP行動互聯網開發之檔案的上傳下載PHP行動互聯網開發之檔案的上傳下載

 

三、檔案函數函式庫PHP行動互聯網開發之檔案的上傳下載

touch

設定文件的存取與修飾時間

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

copy

複製檔案

#bool copy(string $source, string $dest)

注意:移動檔案請使用rename函數

file_put_contents

將一個字串寫入檔案

int file_put_contents(string $filename, string $data[, int $flag[, resource $content]])

file_get_contents

#將整個檔案讀出字串

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

#四、序列化與反序列化

serialize

序列化

string serialize(mixed $value)

注意:serialize()可處理除了resouce之外的任何類型。甚至可以serialize()那些包含了指向其自身引用的陣列。

unserialize

反序列化

mixed unserialize(string $str)

PHP行動互聯網開發之檔案的上傳下載

PHP行動互聯網開發之檔案的上傳下載

● date

格式化一個本地時間/日期

string date(string format[, int timestamp]);

● getdate

取得日期/時間資訊

array getdate([int timestamp]);

PHP行動互聯網開發之檔案的上傳下載

PHP行動互聯網開發之檔案的上傳下載
## 

#● microtime

傳回目前Unix時間戳與微秒數

mixed microtime([bool get_as_float]);

● date_default_timezone_set

● date_default_timezone_set

預設時區

bool date_default_timezone_set(string timezone_identifier);

● date_default_timezone_get

取得預設時區

string date_default_timezone_get(#vo);

三、字元函數庫

strlen

取得字串長度

int strlen(string $str);

strtolower

字串轉換為小寫

string strtolower(string $str);

strtoupper

##string

#string strtoupper (string $str);

ucfirst

首字母大寫

string ucfirst(string $str);

ucwords

將每個單字的首字母轉換為大寫字母

string ucwords(string $str);

ltrim

從字串開始的位置刪除空格或其他字元

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

rtrim

從字串結束的位置刪除空格或其他字元

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

trim

從字串開始和結束的位置刪除空格或其他字元

str_replace

#字元替換

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

str_ireplace

#字元替換

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

md5

 

計算字串的MD5雜湊

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

strpos

傳回一個字元在另一個字元第一次出現的位置
int strpos(string haystack, mixed needle[, int offset]);

#######  ###

以上是PHP行動互聯網開發之檔案的上傳下載的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn