File Upload progress bar PHP Code This article is the use of PHP a plugin instance mail php file upload progress bar function, the method is relatively simple, because there are components, so long as the person's meaning can be used to instantiate php large file upload function.
File Upload progress bar PHP Tutorial Code
This article is the use of PHP a plugin instance mail php file upload progress bar function, the method is relatively simple, because there are components, so long as the person's meaning can be used to sample PHP large file upload function.
There are two ways I know now, one is to use the APC extension module written by PHP's founder Rasmus Lerdorf (HTTP://PECL.PHP.NET/PACKAGE/APC), Another way to do this is to use the PECL extension uploadprogress implementation (http://pecl.php.net/package/uploadprogress) I'll give you two examples to implement separately for reference, more flexible applications to modify according to their own needs.
APC Implementation method:
Install APC, refer to the Official document installation, you can use the Pecl module installation method quick and simple, here does not explain
Configure the php.ini, set the parameter apc.rfc1867=1, enable APC to support the upload progress bar function, in the APC source code document contains the description
PHP File Upload progress bar Implementation method: Install APC, refer to the Official document installation, you can use the Pecl module installation method quick and simple, here does not explain the configuration php.ini, set the parameters apc.rfc1867=1, so that APC support the upload progress bar function, In the APC source code documentation, there are examples of the codes:
if ($_server[' Request_method ']== ' post ') {//Upload request
$status =apc_fetch (' upload_ ' $_post[' apc_upload_progress ');
$status [' Done ']=1;
Echojson_encode ($status);//output to the user-side page Ajax calls, related documents please find yourself
Exit
}elseif (Isset ($_get[' Progress_key ')) {//Read upload Progress
$status =apc_fetch (' upload_ ' $_get[' Progress_key ');
Echojson_encode ($status);
Exit
}else{
Other code, such as uploading a form, etc.
}
Uploadprogress Module Implementation method: Install the module using the PECL module installation method php file upload progress bar implementation method PHP.ini inside Set uploadprogress.file.filename_template = "/tmp/ Upd_%s.txt "
if ($_server[' Request_method ']== ' post ') {
if (Is_uploaded_file ($_files[' upfile ' [' tmp_name '])) {
$upload _dir= ' your_path/';
$ext =strrchr ($_files[' video ' [' Name '], '. ');
$sessid =$_post[' Upload_identifier '];
$tmpfile = $upload _dir. $sessid;
$sessfile = $upload _dir. $sessid. $ext;
if (Move_uploaded_file ($_files[' upfile ' [' tmp_name '], $tmpfile)) {
Upload successful
}else{
Upload failed
}else{
Upload Error
}elseif (!empty ($_get[' sessid ')) {
Header ("Expires:mon,26jul199705:00:00gmt");
Header ("last-modified:". Gmdate ("D,dmyh:i:s"). " GMT ");
Header ("Cache-control:no-store,no-cache,must-revalidate");
Header ("Cache-control:post-check=0,pre-check=0′,false");
Header ("Pragma:no-cache");
Header ("content-type:text/html;charset=utf-8′");
$unique _id=$_get[' sessid '];
$uploadvalues =uploadprogress_get_info ($unique _id);
if (Is_array ($uploadvalues)) {
echo Json_encode ($uploadvalues);
}else{
Read progress failed, additional processing logic
}
}else{
Show Upload Form
}
PECL Extension Module uploadprogress implementation.
Application analysis of AJAX technology based on PHP
PHP limit upload file size specific solution
How to implement PHP batch upload images
PHP dynamic Multi-file upload specific code sharing
PHP General file Upload class specific analysis I here to give two examples for the implementation of the example for reference, more flexible applications according to their own needs to modify.
APC php File Upload progress bar Implementation method:
Install APC, refer to Official document installation, can use PECL module installation method quick and simple
http://www.bkjia.com/PHPjc/444836.html www.bkjia.com true http://www.bkjia.com/PHPjc/444836.html techarticle File upload progress bar PHP Code This article is the use of PHP a plugin instance mail php file upload progress bar function, the method is relatively simple, because there are components, so long as the people's ...