Zend Framework implementation of multi-file Upload function example, zendframework_php tutorial

Source: Internet
Author: User
Tags zend framework

Zend Framework implements multi-file upload function instances, zendframework

This paper describes the method of Zend framework to implement multi-file upload function. Share to everyone for your reference, as follows:

First step: Find the Library folder in our original tutorial. This is where we stored our Zend Class Library folder. Now we add the following folders to the Library folder: library/custom/controller/plugin/

Folder we joined to complete. This is where we're going to find our file upload class file. Here I name the upload.php file name: This file is the class file that we are going to use to upload the file. Of course this file I was rewritten into the Zend Framework plug-in form ... upload.php part of the file is described below, (I only give some of the program, that is, a simple multi-File upload Class):

<?phpclass Custom_controller_plugin_upload extends Zend_controller_plugin_abstract {private $uploaddir;// File upload path private $max _files; How many files are uploaded at once private $max _size; Maximum number of files private $permission; Whether the folder can have permissions private $files;p rivate $allowed = Array (); Allow upload file format//Do not allow uploading of file formats private $notallowed = Array ("EXE", "MP3");p rivate $filesname; The file form name//the width of the picture file, creating the thumbnail private $imagewidth; Picture file height, over on the generated thumbnail private $imageheight;p ublic $filearray = Array ();//returns multiple file names public $lastFileName; Add a file name to public $Error;? >

Step two: In our previous tutorial on writing a message book. Locate the controller at that time. indexcontroller.php, add a name called upload action. This upload action is intended to be used when uploading files. Its detailed procedures are as follows:

Public Function uploadaction () {echo $this->view->render (' header.phtml ');//display modulo masthead file if (Strtolower ($_server[') Request_method ']) = = ' Post ') {Zend_loader::loadclass (' custom_controller_plugin_upload '); $uploadfile =new Custom_ Controller_plugin_upload (root_dir. '/public/upload/', ' uploadfile ', ' ten ', ' 2048000 ', Array ("GIF", "png", "JPG", "BMP", "JPEG"), 600,600), if (' = = $uploadfile->error) {echo ' Congratulations, photo upload successful! Please view->baseurl. ' /index/index/"> Click here to return ';} Else{echo ' Sorry, your photo upload has the following error: '. $uploadfile->error. ' Please return to re-upload! Please view->baseurl. ' /index/upload/"> Click here to return ';}} echo $this->view->render (' message/upload.phtml ');//display template echo $this->view->render (' footer.phtml ');// Show template Foot File}

Step three: Add the Upload function form form to our view Template folder.: Here I add a upload.phtml template file in Riga ... In order to let everyone better see how to implement the upload. I only write one of the simplest upload file forms: It's not too hard to realize ... We just need to be in this view template file. We can upload the file by pointing the action of its post to our upload.

Finally, all you need is to enter your website address. For example, my: only you in the upload form to select the image file. You can upload it. There's nothing wrong with that. The file you just uploaded will be in the Site Directory zendframework/public/upload/the folder below. There is no mistake in taking exams. Because I only control the upload as a picture file here. You can change to another file that you want to upload.

More interested in Zend related content readers can view the topic: "Zend framework of the introductory tutorial", "PHP Excellent Development Framework Summary", "Yii framework Introduction and common skills Summary", "thinkphp Introductory Tutorial", "PHP object-oriented Programming introduction tutorial "," Introduction to Php+mysql Database Operation "and" PHP common database Operation Skills Summary "

It is hoped that this article will help you to design PHP based on the Zend Framework framework.

Articles you may be interested in:

    • Zend Framework Framework Tutorial Zend_db_table_rowset Usage Example Analysis
    • Zend Framework Tutorial Zend_db_table_row Usage Example Analysis
    • Zend Framework Tutorial Zend_db_table Usage
    • Zend Framework Tutorial Zend_form component implement form submission and display Error prompt method
    • Introduction to Zend Framework Development Classic Tutorial
    • Zend Framework Smarty Extension Implementation method
    • Code analysis of routing mechanism of Zend framework framework
    • Zend Framework implementation of basic functions of the message book (with demo source download)
    • The Zend framework implements the method of storing the session in Memcache
    • Zend Framework Paging Class usage
    • Zend Framework Introduction Environment configuration and the first Hello World example (with demo source download)
    • Zend Framework Tutorial to connect the database and perform additions and deletions of the method (attached to the demo source download)
    • Zend Framework Tutorial Zend_db_table Table Association Instance detailed

http://www.bkjia.com/PHPjc/1113737.html www.bkjia.com true http://www.bkjia.com/PHPjc/1113737.html techarticle Zend Framework implements a multi-file Upload function example, zendframework This article describes the Zend framework to implement the multi-file upload function method. Share to everyone for your reference, as follows ...

  • 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.