


Zend Framework implements the multi-file upload function example, zendframework
This article describes the Zend Framework method of implementing the multi-file upload function. Share it with everyone for your reference, the details are as follows:
Step one: Find the library folder in our original tutorial. This is where our Zend class library folder is stored. Now we add the following folders to the library folder: library/Custom/Controller /Plugin/
We have finished adding the folder. Now we have to find the class file for our file upload. Here I named it Upload.php file name. This file is the class file we will use for file upload. Of course, I rewrote this file into a plug-in form in Zend Framework... Part of the file description of Upload.php is as follows (I only give part of the program here, which is a simple multi-file upload class):
<?php class Custom_Controller_Plugin_Upload extends Zend_Controller_Plugin_Abstract { private $uploaddir; //文件上传存路径 private $max_files; //一次性最多上传多少文件 private $max_size; //文件最大量 private $permission; //文件夹是否可以有权限 private $files; private $allowed = array (); //允许上传文件格式 //不允许上传文件格式 private $notallowed = array ("exe", "mp3" ); private $filesname; //文件表单name //图片文件宽度,超过就生成缩略图 private $imagewidth; //图片文件高度,超过就生成缩略图 private $imageheight; public $filearray = array (); //返回多个文件名 public $lastFileName; //返加一个文件名 public $Error; ?>
Step 2: In our previous tutorial on writing a guestbook...find the controller at that time...IndexController.php, and add an action called upload. This upload action is for uploading files. The detailed procedure for using it is as follows:
public function uploadAction() { echo $this->view->render('header.phtml');//显示模版头文件 if(strtolower($_SERVER['REQUEST_METHOD'])=='post'){ Zend_Loader::loadClass('Custom_Controller_Plugin_Upload'); $uploadfile=new Custom_Controller_Plugin_Upload( ROOT_DIR.'/public/upload/','uploadfile','10','2048000', array("gif","png","jpg","bmp","jpeg"),600,600); if(''==$uploadfile->Error){ echo '<div class="commentInner" style="width:860px;text-align:center;"> 恭喜您,照片上传成功!请您<a style="color:red;" href= "'.$this->view->baseUrl.'/index/index/">点这里返回</a></div>'; }else{ echo '<div class="commentInner" style="width:860px;text-align:center;"> 对不起,您照片上传有以下错误:'.$uploadfile->error.'请返回重新上传!请您 <a style="color:red;" href="'.$this->view->baseUrl.'/index/upload/"> 点这里返回</a></div>'; } } echo $this->view->render('message/upload.phtml');//显示模版 echo $this->view->render('footer.phtml');//显示模版脚文件 }
Step 3: Add the upload function Form form to our View template folder...: Here I have added an upload.phtml template file in Riga... In order to let everyone better see how to implement uploading. .I will only write the simplest file upload form. It will not be too difficult to implement... We only need to point its POST action to our upload action in this View template file to upload files. Got it..
Finally, all you need is to enter your website address. For example, mine: http://127.0.0.1/zendframework/index/upload/ This only requires you to select the image file in the upload form.. and you can upload it. Okay.. If there is nothing wrong, the file you just uploaded will be under the folder zendframework/public/upload/ in the website directory. There will be no mistakes in the test. Because I only control uploading as image files here. You can change it. into other files you want to upload..
Readers who are interested in more zend-related content can check out the special topics of this site: "Zend FrameWork Framework Introductory Tutorial", "php Excellent Development Framework Summary", "Yii Framework Introduction and Summary of Common Techniques", "ThinkPHP Introductory Tutorial" , "php object-oriented programming introductory tutorial", "php mysql database operation introductory tutorial" and "php common database operation skills summary"
I hope this article will be helpful to everyone’s PHP programming based on the Zend Framework framework.
Articles you may be interested in:
- Zend Framework Tutorial - Zend_Db_Table_Rowset Usage Example Analysis
- Zend Framework Tutorial - Zend_Db_Table_Row Usage Example Analysis
- Zend Framework Tutorial: Detailed explanation of Zend_Db_Table usage
- Zend Framework tutorial: Zend_Form component to implement form submission and display error prompts
- Zend Framework development introduction classic tutorial
- Zend Framework Smarty extension implementation Method
- Zend Framework routing mechanism code analysis
- Zend Framework implements a guestbook with basic functions (with demo source code download)
- Zend Framework implements session storage in memcache Method
- Detailed explanation of usage of Zend Framework paging class
- Environment configuration for getting started with Zend Framework and the first Hello World example (with demo source code download)
- Link to Zend Framework tutorial Database and method to perform add/delete query (with demo source code download)
- Detailed explanation of the Zend_Db_Table table association instance in the Zend Framework tutorial

.NETFramework4是开发人员和最终用户在Windows上运行最新版本的应用程序所必需的。但是,在下载安装.NETFramework4时,许多用户抱怨安装程序在中途停止,显示以下错误消息-“ .NETFramework4hasnotbeeninstalledbecauseDownloadfailedwitherrorcode0x800c0006 ”。在您的设备上安装.NETFramework4时,如果您也在体验它,那么您就来对了地方

每当您的Windows11或Windows10PC出现升级或更新问题时,您通常会看到一个错误代码,指示故障背后的实际原因。但是,有时,升级或更新失败可能不会显示错误代码,这时就会出现混淆。有了方便的错误代码,您就可以确切地知道问题出在哪里,因此您可以尝试修复。但是由于没有出现错误代码,因此识别问题并解决它变得极具挑战性。这会占用您大量时间来简单地找出错误背后的原因。在这种情况下,您可以尝试使用Microsoft提供的名为SetupDiag的专用工具,该工具可帮助您轻松识别错误背后的真
![SCNotification 已停止工作 [修复它的 5 个步骤]](https://img.php.cn/upload/article/000/887/227/168433050522031.png)
作为Windows用户,您很可能会在每次启动计算机时遇到SCNotification已停止工作错误。SCNotification.exe是一个微软系统通知文件,由于权限错误和点网故障等原因,每次启动PC时都会崩溃。此错误也以其问题事件名称而闻名。因此,您可能不会将其视为SCNotification已停止工作,而是将其视为错误clr20r3。在本文中,我们将探讨您需要采取的所有步骤来修复SCNotification已停止工作,以免它再次困扰您。什么是SCNotification.e

已安装Microsoft.NET版本4.5.2、4.6或4.6.1的MicrosoftWindows用户如果希望Microsoft将来通过产品更新支持该框架,则必须安装较新版本的Microsoft框架。据微软称,这三个框架都将在2022年4月26日停止支持。支持日期结束后,产品将不会收到“安全修复或技术支持”。大多数家庭设备通过Windows更新保持最新。这些设备已经安装了较新版本的框架,例如.NETFramework4.8。未自动更新的设备可能

Inthisarticle,wewilllearnhowtoallowmultiplefilesuploadsinHTMLforms.我们使用多个属性,以允许在HTML表单中进行多个文件上传。多个属性适用于电子邮件和文件输入类型。Ifyouwanttoallowausertouploadthefiletoyourwebsite,youneedtouseafileuploadbox,alsoknownasafile,selectbox.Thisiscreatedusingthe<in

自我们谈论影响安装KB5012643forWindows11的用户的新安全模式错误以来已经过去了一周。这个讨厌的问题并没有出现在微软在发布当天发布的已知问题列表中,因此让所有人都感到意外。好吧,就在您认为情况不会变得更糟的时候,微软为安装此累积更新的用户投下了另一颗炸弹。Windows11Build22000.652导致更多问题因此,这家科技公司警告Windows11用户,他们在启动和使用某些.NETFramework3.5应用程序时可能会遇到问题。听起来很熟悉?不过请不要惊

如何在Zend框架中使用ACL(AccessControlList)进行权限控制导言:在一个Web应用程序中,权限控制是至关重要的一项功能。它可以确保用户只能访问其有权访问的页面和功能,并防止未经授权的访问。Zend框架提供了一种方便的方法来实现权限控制,即使用ACL(AccessControlList)组件。本文将介绍如何在Zend框架中使用ACL

PHP实现框架:ZendFramework入门教程ZendFramework是PHP开发的一种开源网站框架,目前由ZendTechnologies维护,ZendFramework采用了MVC设计模式,提供了一系列可重用的代码库,服务于实现Web2.0应用程序和Web服务。ZendFramework深受PHP开发者的欢迎和推崇,拥有广泛


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version
Recommended: Win version, supports code prompts!
