Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate profile picture uploader in zend framework
    primarykey
    data
    text
    <p>I have recently started working on zend framework. I want to upload a profile picture and rename &amp; re-size it. Am using the code below. with this am able to upload but am not able to rename and am not getting a way to re-size the uploaded file.</p> <p>if($this->getRequest()->isPost()) {</p> <pre><code> if(!$objProfilePictureForm-&gt;isValid($_POST)) { //return $this-&gt;render('add'); } if(!$objProfilePictureForm-&gt;profile_pic-&gt;receive()) { $this-&gt;view-&gt;message = '&lt;div class="popup-warning"&gt;Errors Receiving File.&lt;/div&gt;'; } if($objProfilePictureForm-&gt;profile_pic-&gt;isUploaded()) { $values = $objProfilePictureForm-&gt;getValues(); $source = $objProfilePictureForm-&gt;profile_pic-&gt;getFileName(); //to re-name the image, all you need to do is save it with a new name, instead of the name they uploaded it with. Normally, I use the primary key of the database row where I'm storing the name of the image. For example, if it's an image of Person 1, I call it 1.jpg. The important thing is that you make sure the image name will be unique in whatever directory you save it to. $new_image_name = 'new'; //save image to database and filesystem here $image_saved = move_uploaded_file($source, '../uploads/thumb'.$new_image_name); if($image_saved) { $this-&gt;view-&gt;image = '&lt;img src="../uploads/'.$new_image_name.'" /&gt;'; $objProfilePictureForm-&gt;reset();//only do this if it saved ok and you want to re-display the fresh empty form } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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