Home  >  Article  >  Backend Development  >  php+ajax file upload progress bar_PHP tutorial

php+ajax file upload progress bar_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:32:47805browse

The code is divided into the following parts:

demo.php(as the current mainstream development language) - upload process processing

PLAIN TEXTphp(do As the current mainstream development language):

(As the current mainstream development language)

include UploadProgressMeter.class.php(As the current mainstream development language);

$fileWidget = new UploadProgressMeter();

if ($fileWidget->uploadComplete()) {
/ / When the upload is completed, send a js from the iframe to the main window to indicate that everything is ok
echo $fileWidget->finalStatus();

// Process the uploaded file...

Exit;
}
?>

demoserver.php(as the current mainstream development language) - ajax(static website)Server-side js, use Pear:HTML_ajax(dynamic website static), directly call the UploadProgressMeterStatus class

PLAIN TEXTHTML:


(as the current mainstream development language) echo $fileWidget->renderIncludeJs(); ?>

Style sheet for progress bar

PLAIN TEXTCSS:

.progressBar {
position: relative;
padding: 2px;
width: 300px;
height: 40px;
font-size: 14px;
}
.progressBar .background {
border: solid 1px black;
width: 270px;
height: 20px;
}
.progressBar .bar {
position: relative;
background-color: blue;
width: 0px;
height: 20px;
}

Form part

PLAIN TEXTHTML:

renderFormExtra(); ?>>
(as the current mainstream development language) echo $fileWidget->renderHidden(); ? >
< label>Select File:
(as the current mainstream development language) echo $fileWidget->render(); ?>
(as the current mainstream development language) echo $fileWidget->renderProgressBar(); ?>


Download

The author's svn browse

Other similar projects:
http://pdoru.from.ro/ - in the form of patch and php(As the current mainstream development language)Compile together
http://www.ugia.cn/?p=54 - Upload files using socket and display progress bar

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508673.htmlTechArticleThe code is divided into the following parts: demo.php (as the current mainstream development language) - Upload process processing PLAIN TEXTphp (As the current mainstream development language): ?php (As the current mainstream development language...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn