Кемеровские программисты php общаются здесь
Anonymous
Как изменить размер изображения при загрузке в ZF2
Сообщение
Anonymous » 09 июл 2024, 05:15
Я новичок в работе с Zend Frame, и мне нужно реализовать изменение размера изображения при загрузке в Zend Framework 2. Я пытаюсь использовать метод изменения размера изображения zf2, но у меня он не сработал.
пожалуйста, помогите?
публичная функция addAction(){
Код: Выделить всё
$form = new ProfileForm();
$request = $this->getRequest();
if ($request->isPost()) {
$profile = new Profile();
$form->setInputFilter($profile->getInputFilter());
$nonFile = $request->getPost()->toArray();
$File = $this->params()->fromFiles('fileupload');
$width = $this->params('width', 30); // @todo: apply validation!
$height = $this->params('height', 30); // @todo: apply validation!
$imagine = $this->getServiceLocator()->get('my_image_service');
$image = $imagine->open($File['tmp_name']);
$transformation = new \Imagine\Filter\Transformation();
$transformation->thumbnail(new \Imagine\Image\Box($width, $height));
$transformation->apply($image);
$response = $this->getResponse();
$response->setContent($image->get('png'));
$response
->getHeaders()
->addHeaderLine('Content-Transfer-Encoding', 'binary')
->addHeaderLine('Content-Type', 'image/png')
->addHeaderLine('Content-Length', mb_strlen($imageContent));
return $response;
$data = array_merge(
$nonFile,
array('fileupload'=> $File['name'])
);
$form->setData($data);
if ($form->isValid()) {
$size = new Size(array('min'=>100000)); //minimum bytes filesize
$adapter = new \Zend\File\Transfer\Adapter\Http();
$adapter->setValidators(array($size), $File['name']);
if (!$adapter->isValid()){
$dataError = $adapter->getMessages();
$error = array();
foreach($dataError as $key=>$row)
{
$error[] = $row;
}
$form->setMessages(array('fileupload'=>$error ));
} else {
$adapter->setDestination('./data/tmpuploads/');
if ($adapter->receive($File['name'])) { //identify the uploaded errors
$profile->exchangeArray($form->getData());
echo 'Profile Name '.$profile->profilename.' upload '.$profile->fileupload;
}
}
}
}
return array('form' => $form);
}
Относится к :-image resize zf2
Подробнее здесь:
https://stackoverflow.com/questions/243 ... ing-in-zf2
1720491321
Anonymous
Я новичок в работе с Zend Frame, и мне нужно реализовать изменение размера изображения при загрузке в Zend Framework 2. Я пытаюсь использовать метод изменения размера изображения zf2, но у меня он не сработал. пожалуйста, помогите? публичная функция addAction(){ [code] $form = new ProfileForm(); $request = $this->getRequest(); if ($request->isPost()) { $profile = new Profile(); $form->setInputFilter($profile->getInputFilter()); $nonFile = $request->getPost()->toArray(); $File = $this->params()->fromFiles('fileupload'); $width = $this->params('width', 30); // @todo: apply validation! $height = $this->params('height', 30); // @todo: apply validation! $imagine = $this->getServiceLocator()->get('my_image_service'); $image = $imagine->open($File['tmp_name']); $transformation = new \Imagine\Filter\Transformation(); $transformation->thumbnail(new \Imagine\Image\Box($width, $height)); $transformation->apply($image); $response = $this->getResponse(); $response->setContent($image->get('png')); $response ->getHeaders() ->addHeaderLine('Content-Transfer-Encoding', 'binary') ->addHeaderLine('Content-Type', 'image/png') ->addHeaderLine('Content-Length', mb_strlen($imageContent)); return $response; $data = array_merge( $nonFile, array('fileupload'=> $File['name']) ); $form->setData($data); if ($form->isValid()) { $size = new Size(array('min'=>100000)); //minimum bytes filesize $adapter = new \Zend\File\Transfer\Adapter\Http(); $adapter->setValidators(array($size), $File['name']); if (!$adapter->isValid()){ $dataError = $adapter->getMessages(); $error = array(); foreach($dataError as $key=>$row) { $error[] = $row; } $form->setMessages(array('fileupload'=>$error )); } else { $adapter->setDestination('./data/tmpuploads/'); if ($adapter->receive($File['name'])) { //identify the uploaded errors $profile->exchangeArray($form->getData()); echo 'Profile Name '.$profile->profilename.' upload '.$profile->fileupload; } } } } return array('form' => $form); } [/code] Относится к :-image resize zf2 Подробнее здесь: [url]https://stackoverflow.com/questions/24364346/how-to-resize-a-image-while-uploading-in-zf2[/url]
Превышает определенный размер ini с использованием формы ZF2
Anonymous »
03 июл 2024, 08:21 » в форуме
Php
Я получаю эту ошибку при попытке выполнить загрузку файлов.
if ($request->isPost()) {
$form->setInputFilter($language->getInputFilter());
$nonFile = $request->getPost()->toArray();
$File = $this->params()->fromFiles('fileupload');
$data =...
0 Ответы
18 Просмотры
Последнее сообщение Anonymous
03 июл 2024, 08:21
0 Ответы
42 Просмотры
Последнее сообщение Anonymous
15 мар 2024, 07:01
Вложенный запуск событий в ZF2
Anonymous »
22 май 2024, 03:58 » в форуме
Php
Я использую этот код для запуска события:
$input = array(1,2,3);
$result = $EventManager->trigger('onChangeArray',$this,array('values'=>$input));
$c = $result->count();
$final = array();
for($i=0; $ipop());
Я хочу изменить этот массив в функции...
0 Ответы
15 Просмотры
Последнее сообщение Anonymous
22 май 2024, 03:58
0 Ответы
20 Просмотры
Последнее сообщение Anonymous
02 июл 2024, 02:34
Флэш-мессенджер в zf2
Anonymous »
05 июл 2024, 09:54 » в форуме
Php
Как использовать Flash Messenger в Zend Framework 2? Документации сессии пока нет. Кто-нибудь это знает? Но библиотеки сессий существуют.
Подробнее здесь:
0 Ответы
17 Просмотры
Последнее сообщение Anonymous
05 июл 2024, 09:54