Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to resize uploaded image in zend framework
    text
    copied!<p>I have a form with upload image field. How to resize the recently uploaded image to desired size? My current form is :</p> <pre><code>&lt;?php class Application_Form_User extends Zend_Form { public function init() { $this-&gt;setAttrib('enctype', 'multipart/form-data'); $this-&gt;setAction(""); $this-&gt;setMethod("post"); $element = new Zend_Form_Element_File('photo'); $element-&gt;setLabel('Upload an image:') -&gt;setValueDisabled(true); $this-&gt;addElement($element, 'photo'); $element-&gt;addValidator('Count', false, 1); // limit to 1000K $element-&gt;addValidator('Size', false, 1024000); // only JPEG, PNG, and GIFs $element-&gt;addValidator('Extension', false, 'jpg,png,gif'); $submit = $this-&gt;createElement('submit', 'submit'); $submit-&gt;setLabel('Save'); $this-&gt;addElement($submit); } </code></pre> <p>}</p> <p>And my controller:</p> <pre><code>public function indexAction() { $form=new Application_Form_User(); if ($this-&gt;getRequest()-&gt;isPost()) { $formData = $this-&gt;getRequest()-&gt;getPost(); if ($form-&gt;isValid($formData)) { $file=pathinfo($form-&gt;photo-&gt;getFileName()); $form-&gt;photo-&gt;addFilter('Rename', PUBLIC_PATH.'/images/'.uniqid().time().'.'.$file['extension']); if ($form-&gt;photo-&gt;receive()) { $this-&gt;view-&gt;photo=pathinfo($form-&gt;photo-&gt;getFileName()); } } } $this-&gt;view-&gt;form=$form; } </code></pre> <p>Can somebody provide me with an example? How can i use plugins like php thumbnailer or similar plugin to resize the uploaded image?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload