zend-framework,zend-form , Zend File Create folder while uploading

Zend File Create folder while uploading


Tag: zend-framework,zend-form

With this form element I'm uploading a file:

$element = new Zend_Form_Element_File('foo');
$element->setLabel('Upload Image1:')

$element->addValidator('Count', false, 1);
$element->addValidator('Size', false, 102400);
$element->addValidator('Extension', false, 'jpg,png,gif');
$form->addElement($element, 'foo');

This requires that the folder is already existing. How can I add an option, that the folder is beeing created, but only if a user selects a file and the upload succeeds?


You will have to remove ->setDestination from your form and put it in your controller.

The following is what you will put in your controller.

$upload = new Zend_File_Transfer_Adapter_Http();
if (//code to check if folder '/var/www/upload' does not exist)
//code to create a folder '/var/www/upload' and then set destination to that folder


Zend Framework 2 - Sending form using Zend\Mail

So i'm making a contact page. Of course it will have a form, which needs to be sent. I made the class to send email: <?php namespace Site\Mail; use Zend\Mail\Message; use Zend\Mail\Transport\Sendmail; class SendEMail { public function SendEMail($to, $from, $subject, $body) { $message = new Message(); $message->addTo($to) ->addFrom($from) ->setSubject($subject) ->setBody($body);...

zend 1 xsd validation

I am building a simple API end-point in ZF1 and got to the stage of XML validation. I could not find it anywhere in Zend documentation, so maybe someonehas come accross this before: Does Zend Framework 1 has any kind of library or wrapper for validating XML against XSD? or...

Zend date validator fail for format dd-mm-yyyy

I have the following code: <?php $dateString = '12.12.12'; $dateCheckArray['format'] = 'dd-mm-yyyy'; $validator = new Zend_Validate_Date($dateCheckArray); if ($validator->isValid($dateString)) { echo 'valid'; } else { echo 'invalid'; } The code works ok for most formats, but for the one specified it fails when using a . date instead of a -...

Get Google Plus Images Using Zend Framework 1 Gdata

I've been searching for an answer for this for quite some time now. I've looked into the other questions here but couldn't find a relevant one to my situation. Googling the question wasn't helpful as well. Basically, I am using ZF1's Gdata class to access the photos api. This was...

Zend framework - how can i update the row if status field and id match?

How to updates the status='ok' only when status is NULL or done or notdone and id matches? $this->db->update('table1', array('status' => 'ok'), array('id=?' => 55)); ...

ZEND_Auth, deactivate navigation area

I´ve built a Login Page using Zend_Auth. Now my question ist how can I deactivate areas which are loaded with my layout.phtml? Here the part of my code of my layout.phtml which I don´t want to see in my login and logout forms: <div id="navigation"> <ul> <li><a href="<?php echo $this->url(array('controller'=>'arbeitskalender',...

Object of class Zend_Db_Table_Row could not be converted to string

I get the error message in the title when I run the following: $year = date('Y'); $month = date('n'); $day = date('j') - 3; $week = date('W') - 1; $select = "SELECT IF( station_name = '', 'Unknown', station_name ) station_name, station_name as db_name, sum(case when year(print_date) = $year then print_pages...

File upload form validation invalid

Current form: $main = new Zend_Form_SubForm(); $kids = new Zend_Form_SubForm(); $number = $main->addElement(... attribs and so on ...); $this->addSubForms(array('main'=>$main,'kids'=>$kids)); When I'm adding this file upload fields to my form: for($index = 1; $index <= 10; $index++) { $name = 'Image'.$index; $label = 'Image'.$index; $image = new Zend_Form_Element_File($name); $image->setLabel($label) ->addValidator('Count', true,...

Bootstrap of Zend Module is not loading

I am new in working with zend so I am facing this problem from the past two days. I have searched a lot but still can not find any solution. Possible duplicate of Zend Module Bootstrap does not load but it still can not solve my problem. In my User...

Overriding ZF2 global/local config: unsetting

I've run into a problem where my local config overrides global but I need local to remove not just override. E.g. // global.php 'mail_transport' => [ 'type' => 'Zend\Mail\Transport\Smtp', 'options' => [ 'host' => 'smtp.gmail.com', 'port' => 587, 'connectionClass' => 'login', 'connectionConfig' => [ // ... ], ], ], //...

is not null condition in zend framework 2

I am new to zf and I've started working with zf2, I don't find much documentation for the syntax and all. My issue is how to write is not null condition in zf2 syntax. $select->where->notEqualTo('pe_name', ''); I've written for not equal to, now I need for is not null. I...

Understanding bootstrap, config.php, application.ini

I´m still beginner with Zend Framework. If I read different articles I wonder which are the differences between the three configuration files, bootstrap.php, config.php and application.ini. I only use the application.ini, my bootstrap so far ist empty (of course it is called in my index.php), at the moment I don´t...

Zend Framework 2 Form Errors Not Showing

I am trying to figure out why Zend Form is not returning errors to my form. When I take a look inside the: Zdendframework/library/form/form.php file I can see the errors are being generated: public function isValid() { if ($this->hasValidated) { return $this->isValid; } ... if (!$result) { $this->setMessages($filter->getMessages()); } return...

Zend 1 3d party NameSpaces autoload don't working

I'm trying to implement Amazon WebServices PHP SDK into my Zend 1 project, but it seems to fail loading the classes. I have got the library into library/Eplan/AmazonCloudSearch and after investigation it seems that in order to be able to load the namespace I need to call the registerNamespace method...

Zend InputFilter requires intl PHP extension?

I am setting up some filters and validators for my form, but when I submit it, this error appears: "Zend\I18n\Filter component requires the intl PHP extension". Is this because of the Alnum and Alpha validators ? Code: public function getInputFilter() { if (!$this->inputFilter) { $inputFilter = new InputFilter(); $inputFilter->add(array( 'name'...

Zend Framework 2 routing error: resolves to invalid controller class or alias

I'm trying to learn Zend Framework 2 and I have their skeleton application up and running. In order to access it I visit http://localhost:8080/. When visiting that link it displays their generic Zend page. What I want to be able to do is visit http://localhost:8080/application/test and have it bring me...

Zend 1 Redirect to controller from library

$this->_helper->redirector('save', 'index', 'report', $params); This does not work when i use it from a library file It says Fatal error: Call to undefined method Mylib::getHelper(). But When used from controller it works properly. Can any guide me with code what I need to do?...

PHP ZF2 Mysql has gone away

Hi I have a php daemon that handle request from rabbitmq After a day, it can no longer execute due to error MySQL has gone away. PHP Warning: PDOStatement::execute(): MySQL server has gone away in /var/www/daemon/www/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver/Pdo/Statement.php on line 239 PHP Warning: PDOStatement::execute(): Error reading result set\'s header in /var/www/daemon/www/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver/Pdo/Statement.php on...

ZF2 - Display image in view based on full path

I have managed to upload image file in ZF2 and store full path in the database. Path looks like this: /home/ubuntu/NetBeansProjects/project/data/upload/event_5554a7b600c0f.jpg Project structure is a Zend Skeleton application: project data upload event_5554a7b600c0f.jpg module public In my view I call: <img src="<?php echo $event->getImage(); ?>" class="img-thumbnail" alt="<?php echo $event->getTitle(); ?>" width="304"...

How to send field name for required true validation in zend

Here is what my form field, $this->addElement( 'text', 'title', array( 'placeholder' => 'Title', 'class' => 'form-control', 'required' => true, 'filters' => array( 'StringTrim' ), 'autocomplete' => 'off', ) ); I Simply need the error string like: Title is required and can't be empty....

How to manage Zend session save handler using Zend?

I want to save zend session in memcache rather than files bases session management. I have correctly added memcache.dll file in Windows 8 x64 system and check that memcache is working fine and have also installed memcached and windows services showing memcached Server running. I have searched so far for...

Zend File Create folder while uploading

With this form element I'm uploading a file: $element = new Zend_Form_Element_File('foo'); $element->setLabel('Upload Image1:') ->setDestination('/var/www/upload'); $element->addValidator('Count', false, 1); $element->addValidator('Size', false, 102400); $element->addValidator('Extension', false, 'jpg,png,gif'); $form->addElement($element, 'foo'); This requires that the folder is already existing. How can I add an option, that the folder is beeing created, but only if a...

controller action not found on production server

In my development area (wamp) everything works fine. Today I uploaded my whole project to my production webspace. I seems like in the production area, some paths are lost. First I saw that in my start layout (ZEND_Layout) my pictures aren't found. So I needed to change the paths to...

Fetch the maximum value of a field having same id in php

Here's my code,I need to return all the InstallmentDate's along with the return data,the issue here is I have same OrderInstallmentDetailsId for multiple InstallmentDate's. $select = $this->select() ->setIntegrityCheck(false) ->from(array('j' => DB_TABLE_PREFIX . 'finance_journal'), array( '*', 'JournalCreatedDate' => 'CreatedDate' )) ->join(array('jr' => DB_TABLE_PREFIX . 'finance_journal_reference'), 'j.JournalId = jr.JournalId', array( 'totalDebitAmount' =>...

PHP - how to send png or jpg email attachment?

I am using mandrillapp for mailing using following method. But i need to send JPEG or PDF or PNG scan copy from scanner. How can i do that please? public static function sendBcc($from, $to, $subject, $htmlBody, $bcc = '', $bcc1 = '', $utype = '') { $bcc = '', $bcc1...

Zend And YouTube Not Deleting Videos

Until yesterday I could delete YouTube videos using Zend framework. I was using this code: $httpClient = Zend_Gdata_ClientLogin::getHttpClient( $username, $password, 'youtube', null, 'MySite', null, null, 'https://www.google.com/accounts/ClientLogin'); $yt = new Zend_Gdata_YouTube($httpClient, '', '', $myDevKey); $vid = $yt->getVideoEntry($myVidID, null, true); $yt->delete($vid); Now I am getting this error: Expected response code 200, got...

ZF Error ZF tool setup

Zend 1.9.1 so I get this error Blockquote ***************************** ZF ERROR ******************************** In order to run the zf command, you need to ensure that Zend Framework is inside your include_path. If you are running this without Zendframework in your include-path, you can alternatively set one of two enviroment variables to...

Zend Skeleton Application album tutorial 404

As far as I can see I've followed the Zend skeleton application tutorial to the letter (I actually went through it twice with the same result) but when I try to access zf2-tutorial.localhost/album I get the following error: A 404 error occurred Page not found. The requested URL could not...

Password protecting Apigility admin UI without htpasswd

I was being searching to password protect apiglity admin ui without using htpasswd, but i did not got any information about. Can anybody help me out with this? Thanks in advance...

Failed installation of zend-escaper with Composer

I'm trying to install zend-escaper but I'm getting this error: This is strange as my PHP version (from phpinfo()) is 5.5.19, the message claims it is 5.3.5(!) which should satisfy the requirement anyway. My ZF version is 1.12.13 I'm using PHP Storm Can anyone help please? Thanks Tomasz...

How to route pages using text instead of IDs?

Currently, my Zend application routes using the URL: example.com/news/12 Selects the news with ID 12 to display on page. But the client wants to use only text, example: example.com/news/man-dies-after-burning-himself Does someone knows how can it be done?...

Pass array on url using zend framework 2 routes

I have a web app that lets user make multiple searches and show the results of that searches all on the same page. Here's a basic structure: Search 1 - Attribute 1 = X - Attribute 3 = Y Search 2 -Attribute 2 = Z All these results are loaded...

Socialengine addon Advanced Events Plugin v4.8.8p2 throwing errror on create

I've got a site set up with the base Socialengine setup going. I've installed most of the SocialEngineAddon suite of plugins, and for some reason, the Advanced Events plugin throws this error when I try and create one ie: example.com/appeals/create I've tried renaming back to the default site-event, but the...

Zend Framework 2 Cache filesystem

I've been using the filesystem adapter for cacheing data. E.g.. $cache = StorageFactory::factory(array( 'adapter' => array( 'name' => 'filesystem' 'options' => array('ttl' => 1800, 'cache_dir' => './data/cache'), ), )); But when using the getItem() function AFTER the TTL clocks over it returns false on success etc, which it should... However,...

Zend paginator with AJAX

I have multiple albums listed on a page, next to each album are listed reviews about the album. Essentially this means there are many reviews about many albums on a single page. What would be the best approach to paginate each review section for each album? For example so each...

Wrong datatype for referenced entity on Doctrine ObjectSelect

I have a form which uses Doctrine's ObjectSelect to make a dropdown $this->add(array( 'name' => 'category', 'type' => 'DoctrineModule\Form\Element\ObjectSelect', 'options' => array( 'label' => 'Category', 'object_manager' => $em, 'target_class' => 'Blog\Entity\Category', 'property' => 'name' ), 'attributes' => array( 'required' => true ) )); the issue I have, is that this...

ZendX Console Process posix functions

I am catch the follow exception in my code: ZendX_Console_Process_Exception' with message 'posix_* functions are required What's posix function is need for it work right? Thanks...

Transfert a Zend Project to Symfony

I have a project made using Zend. My boss asked me to change the technology to Symfony 2.7. Is there a way to transfer the project ? Or to take some files into Symfony ? Or should I begin all the project from scratch using Symfony ? Thanks !...

zend framework 2 nested module structrue in one main module

I am trying to create a app using zend framework 2. Have used structure as follow. Getting error class not found. Trying to created nested sub module login inside a main module called album. I have following structure: Album - src - Album - Controller - AlbumController.php - Form -...

Is it possible to set a separator for Zend Framework 2 form rows or display them in paragraphs?

I have this for a form $this->add(array( 'name'=>'username', 'type'=>'Text', 'options'=>array( 'label' => 'Username', ) )); $this->add(array( 'name'=>'password', 'type'=>'Password', 'options'=>array( 'label' => 'Password', ) )); and echo $this->formCollection($form); This are obviously just the relevant parts of the code. The output is as follows: <fieldset ><label><span>Username</span><input type="text" name="username"...

Uninstalling php 5.3 in ubuntu 14.04

I have installed php 5.3 manually by executing commands like make & make install. But I need to upgrade it to v5.5 therefore I deleted all the directories related to php5 using sudo command. But when I run php -v Still I am getting PHP 5.3.29 (cli) (built: Jun 8...

Manipulate value in Zend_Registry

I have an array that I write into Zend_Registry: Zend_Registry::set('myArray', $myArray); Now I want to add a new value to that array. I know that Zend_Registry is not a good choice at all and I know that it is kind of read-only. But is there any way to update it?...

Validation for Add screen not working but it working in edit screen with same code

I am learning Zend framework and currently I have created add, update , delete functionality for country name and continent name and it is working perfectly. I have set validation by $name->setRequired('true'); and $continent->setRequired('true'); in my form.php. Validation is working in edit form but it return error 'An error occurred'...

Zend_Pdf how to reduce the loading time of images?

I built an pdf document which is based on database records of 2 related tables. The mastertable contains shopdata with logos. In the records I of course don't save the image itself, but only the pathinfo. The detailtable just contains meeting dates, no problems with this one. If I start...

Pimcore multilanguage site static route

I've just recently started working with Pimcore in my work and I'm now on a project consisting of three languages each in their seperate tree. Today the sites URL is my-site.com/LANGUAGE/sub-page For example: my-site.com/se/about But what we would want to have is LANGUAGE.my-site.com/sub-page. For example: se.my-site.com/about I've tried using the...

Error in Array comparison in php

Below are the sample arrays I'm Comparing. Table 1 $csvData= ( [0] =&gt; Array ( [Account Number] =&gt; 1.01100156278101E+15 [Posting Date] =&gt; 2014/07/08 [Value Date] =&gt; 2014/07/08 [Description] =&gt; Cash Withdrawal by Cheque-173320--TT1421957901 [Debit Amount] =&gt; 2000 [Credit Amount] =&gt; [Running Balance] =&gt; 388392.62 ) [1] =&gt; Array ( [Account...

Php Mysql select query not working

The below query results in the following error: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'AccountId' in where clause is ambiguous $select = $this->select() ->from(array('finance_account' => DB_TABLE_PREFIX . 'finance_account'), array( 'AccountId', 'ParentAccountId', 'AccountGroupId', 'AccountPath', 'AccountCode', 'AccountName', 'Description' )) ->joinLeft(array('ac' => DB_TABLE_PREFIX . 'customer'), 'finance_account.AccountId = ac.AccountId', array()) // using "array_unique()" to...