本文整理汇总了PHP中Zend_File_Transfer_Adapter_Http::setDestination方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_File_Transfer_Adapter_Http::setDestination方法的具体用法?PHP Zend_File_Transfer_Adapter_Http::setDestination怎么用?PHP Zend_File_Transfer_Adapter_Http::setDestination使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_File_Transfer_Adapter_Http
的用法示例。
在下文中一共展示了Zend_File_Transfer_Adapter_Http::setDestination方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _buildAdapter
/**
* Create a ZF HTTP file transfer adapter.
*
* @return void
*/
protected function _buildAdapter()
{
$storage = Zend_Registry::get('storage');
$this->_adapter = new Zend_File_Transfer_Adapter_Http($this->_adapterOptions);
$this->_adapter->setDestination($storage->getTempDir());
// Add a filter to rename the file to something Omeka-friendly.
$this->_adapter->addFilter(new Omeka_Filter_Filename());
}
示例2: uploadphotoAction
public function uploadphotoAction()
{
if ($this->getRequest()->isPost()) {
if ($_FILES['photo']['name'][0] != '') {
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination(Zend_Registry::get('userImagesPath'));
$files = $adapter->getFileInfo();
$i = 1;
foreach ($files as $file => $info) {
if (!$adapter->isUploaded($file)) {
$this->view->sendConfirm = 'Problem uploading files';
return $this->render('error');
}
$extension = strtolower(end(explode('.', $info['name'])));
$name = time() . '4' . $i . "." . $extension;
$i++;
$adapter->addFilter('Rename', array('target' => Zend_Registry::get('userImagesPath') . $name, 'overwrite' => TRUE));
if (!$adapter->receive($info['name'])) {
return $this->render('error');
}
}
$filename = $adapter->getFileName();
$filename = basename($filename);
$profile = array('photo' => $filename);
if (($edited = $this->profileService->editProfile(2, $profile)) === TRUE) {
$this->view->profile = $this->profileService->fetchProfile(2);
} else {
$this->view->profile = $edited;
}
$this->render('getprofile');
}
}
}
示例3: uploadAction
public function uploadAction()
{
if ($code = $this->getRequest()->getPost("code")) {
try {
if (empty($_FILES) || empty($_FILES['file']['name'])) {
throw new Exception("No file has been sent");
}
$path = Core_Model_Directory::getPathTo(System_Model_Config::IMAGE_PATH);
$base_path = Core_Model_Directory::getBasePathTo(System_Model_Config::IMAGE_PATH);
if (!is_dir($base_path)) {
mkdir($base_path, 0777, true);
}
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination($base_path);
if ($adapter->receive()) {
$file = $adapter->getFileInfo();
$config = new System_Model_Config();
$config->find($code, "code");
$config->setValue($path . DS . $file['file']['name'])->save();
$message = sprintf("Your %s has been successfully saved", $code);
$this->_sendHtml(array("success" => 1, "message" => $this->_($message)));
} else {
$messages = $adapter->getMessages();
if (!empty($messages)) {
$message = implode("\n", $messages);
} else {
$message = $this->_("An error occurred during the process. Please try again later.");
}
throw new Exception($message);
}
} catch (Exception $e) {
$data = array("error" => 1, "message" => $e->getMessage());
}
}
}
示例4: changeprofileimgAction
public function changeprofileimgAction()
{
if ($this->getRequest()->isPost()) {
if (!empty($_FILES['photo']['name'])) {
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination(Zend_Registry::get('profileImagesPath'));
$files = $adapter->getFileInfo();
$i = 1;
foreach ($files as $file => $info) {
if (!$adapter->isUploaded($file)) {
return $this->_redirect('/profile');
}
$extension = strtolower(end(explode('.', $info['name'])));
$name = time() . $this->_user->id . $i++ . "." . $extension;
$adapter->addFilter('Rename', array('target' => Zend_Registry::get('profileImagesPath') . $name, 'overwrite' => TRUE));
if (!$adapter->receive($info['name'])) {
$this->view->error = 'There was a problem uploading the photo. Please try again later';
return $this->render('error');
}
}
$filename = $adapter->getFileName();
$filename = basename($filename);
$changes = array('photo' => $filename);
$profileService = new Service_Profile();
if ($edited = $profileService->editProfile($this->_user->profileid, $changes)) {
return $this->_redirect('/profile');
} else {
$this->view->error = 'There was a problem updating your profile. Please try again later';
return $this->render('error');
}
}
} else {
$this->_redirect('/profile');
}
}
示例5: uploadAjaxAction
public function uploadAjaxAction()
{
$this->_helper->layout->setLayout('ajax');
$data = $this->_request->getPost();
$extraDados = "";
if (isset($data['id'])) {
$extraDados = $data['id'] . '-';
}
$path = PUBLIC_PATH . DIRECTORY_SEPARATOR . 'uploads';
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination($path);
// Returns all known internal file information
$files = $upload->getFileInfo();
foreach ($files as $file => $info) {
// Se não existir arquivo para upload
if (!$upload->isUploaded($file)) {
print '<p class="alert alert-warning">Nenhum arquivo selecionado para upload<p>';
continue;
} else {
$fileName = $extraDados . str_replace(' ', '_', strtolower($info['name']));
// Renomeando o arquivo
$upload->addFilter('Rename', array('target' => $path . DIRECTORY_SEPARATOR . $fileName, 'overwrite' => true));
}
// Validação do arquivo ?
if (!$upload->isValid($file)) {
print '<p class="alert alert-danger" > <b>' . $file . '</b>. Arquivo inválido </p>';
continue;
} else {
if ($upload->receive($info['name'])) {
print '<p class="alert alert-success"> Arquivo: <b>' . $info['name'] . '</b> enviado com sucesso e renomeado para: <b>' . $fileName . '</b> </p>';
}
}
}
}
示例6: configAction
function configAction()
{
// When the form is submitted
$form_mess = "";
if (isset($_POST['confName'])) {
$form_mess = $this->updateConfig($_POST, $this->db_v1, $this->view, $this->session);
$this->config_v1 = GetConfig($this->db_v1);
// Check whether the logo file has been transmitted
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination('images/');
$adapter->addValidator('IsImage', false);
if ($adapter->receive()) {
$name = $adapter->getFileName('logo_file');
//récupérer le nom du fichier sans avoir tout le chemin
$name = basename($name);
$this->db_v1->execRequete("UPDATE Config SET logo_file='{$name}'");
}
$config = new Config();
$this->config = $config->fetchAll()->current();
$this->config->putInView($this->view);
$registry = Zend_registry::getInstance();
$registry->set("Config", $this->config);
}
$this->view->config_message = $form_mess;
$this->instantiateConfigVars($this->config_v1, $this->view);
$this->view->setFile("content", "config.xml");
$this->view->setFile("form_config", "form_config.xml");
$form_mess = "";
$this->view->messages = $form_mess;
// N.B: the config values ar eput in the views by the Myreview controller
echo $this->view->render("layout");
}
示例7: updateServicePrice
public function updateServicePrice($data)
{
$db = $this->getAdapter();
$adapter = new Zend_File_Transfer_Adapter_Http();
$part = PUBLIC_PATH . '/images';
$adapter->setDestination($part);
$adapter->receive();
$photo = $adapter->getFileInfo();
if (!empty($photo['photo']['name'])) {
$img = $photo['photo']['name'];
} else {
$img = $data['oldphoto'];
}
if (!empty($photo['photo1']['name'])) {
$img1 = $photo['photo1']['name'];
} else {
$img1 = $data['oldphoto1'];
}
if (!empty($photo['photo2']['name'])) {
$img2 = $photo['photo2']['name'];
} else {
$img2 = $data['oldphoto2'];
}
$arr = array('service_title' => $data['serice_title'], 'description' => $data['description'], 'photo' => $img, 'photo1' => $img1, 'photo2' => $img2, 'price' => $data['price'], 'date' => date("Y-m-d"), 'user_id' => $this->getUserId(), 'status' => $data['status']);
$where = $this->getAdapter()->quoteInto("id=?", $data['id']);
$this->update($arr, $where);
}
示例8: uploadAction
public function uploadAction()
{
try {
if (empty($_FILES) || empty($_FILES['file']['name'])) {
throw new Exception($this->_("No file has been sent"));
}
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination(Core_Model_Directory::getTmpDirectory(true));
if ($adapter->receive()) {
$file = $adapter->getFileInfo();
$data = $this->_getPackageDetails($file['file']['tmp_name']);
} else {
$messages = $adapter->getMessages();
if (!empty($messages)) {
$message = implode("\n", $messages);
} else {
$message = $this->_("An error occurred during the process. Please try again later.");
}
throw new Exception($message);
}
} catch (Exception $e) {
$data = array("error" => 1, "message" => $e->getMessage());
}
$this->_sendHtml($data);
}
示例9: uploadAction
public function uploadAction()
{
try {
if (empty($_FILES) || empty($_FILES['module']['name'])) {
throw new Exception("No file has been sent");
}
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination(Core_Model_Directory::getTmpDirectory(true));
// $adapter->addValidator('MimeType', false, 'application/zip');
if ($adapter->receive()) {
$file = $adapter->getFileInfo();
$parser = new Installer_Model_Installer_Module_Parser();
if ($parser->setFile($file['module']['tmp_name'])->check()) {
$infos = pathinfo($file['module']['tmp_name']);
$filename = $infos['filename'];
$this->_redirect('installer/module/install', array('module_name' => $filename));
} else {
$messages = $parser->getErrors();
$message = implode("\n", $messages);
throw new Exception($this->_($message));
}
} else {
$messages = $adapter->getMessages();
if (!empty($messages)) {
$message = implode("\n", $messages);
} else {
$message = $this->_("An error occurred during the process. Please try again later.");
}
throw new Exception($message);
}
} catch (Exception $e) {
$this->getSession()->addError($e->getMessage());
$this->_redirect('installer/module');
}
}
示例10: uploadFile
public function uploadFile($object, $type, $subtype)
{
$sheets = new SxModule_Sheets();
$base = realpath(APPLICATION_PATH . '/../public_html/securedocs/');
$path = $type . '/' . $subtype;
if (!is_dir($base . '/' . $path)) {
echo $base . '/' . $path;
mkdir($base . '/' . $type);
mkdir($base . '/' . $path);
}
if ($object->getFile() == null) {
$object->setFile('');
}
$uploadAdapter = new Zend_File_Transfer_Adapter_Http();
$uploadAdapter->setDestination($base . '/' . $path);
$uploadAdapter->setOptions(array('ignoreNoFile' => true));
$uploadAdapter->receive();
$files = $uploadAdapter->getFileName(null, true);
foreach ($_FILES['file']['name'] as $key => $filename) {
if (!$filename) {
continue;
}
$file = $base . '/' . $path . '/' . $filename;
$date = date('Y-m-d His');
$path_info = pathinfo($filename);
$myfilename = str_replace(' ', '_', $path_info['filename'] . '_' . $date . '.' . $path_info['extension']);
$myfilename = $sheets->createFileName($myfilename);
$newfile = $base . '/' . $path . '/' . $myfilename;
rename($file, $newfile);
$object->setFile($myfilename);
}
}
示例11: addAction
public function addAction()
{
SxCms_Acl::requireAcl('securedocs', 'securedocs.add');
$base = realpath(APPLICATION_PATH . '/../public_html/securedocs/');
$path = base64_decode($this->_getParam('path'));
if ($this->getRequest()->isPost()) {
$uploadAdapter = new Zend_File_Transfer_Adapter_Http();
$uploadAdapter->setDestination($base . $path);
$uploadAdapter->setOptions(array('ignoreNoFile' => true));
$uploadAdapter->receive();
$files = $uploadAdapter->getFileName(null, true);
foreach ($_FILES['file']['name'] as $key => $filename) {
if (!$filename) {
continue;
}
$summary = $this->_getParam('samenvatting');
$mail = $this->_getParam('mail', '');
$file = $base . $path . '/' . $filename;
$newfile = $base . $path . '/' . str_replace(" ", "", $filename);
rename($file, $newfile);
$file = new SxModule_Securedocs_File($newfile);
$file->setPath($path);
$file->setSummary($summary[$key]);
$file->setMail(isset($mail[$key]) ? "1" : "0");
$file->save();
if ($mail[$key]) {
$groups = explode('/', $path);
$control = $path;
if ($control != "") {
$proxy = new SxModule_Securedocs_Folder_Proxy();
$folder = $proxy->getByFolder($groups[1]);
$folderId = $folder->getFolderId();
$proxy = new SxModule_Securedocs_Group_Proxy();
$groups = $proxy->getAllByMap($folderId);
$aantal = count($groups);
$q = 0;
$groupids = '(';
foreach ($groups as $group) {
$q++;
if ($q != $aantal) {
$groupids .= $group->getGroupId() . ",";
} else {
$groupids .= $group->getGroupId();
}
}
$groupids .= ')';
$proxy = new SxModule_Members_Proxy();
$members = $proxy->getAllByGroups($groupids);
foreach ($members as $member) {
$member->sendDocument($file);
}
}
}
}
$this->_redirect('/admin/securedocs/index/path/' . base64_encode($path));
}
$this->view->path = $path;
$this->view->messages = Sanmax_MessageStack::getInstance('SxModule_Securedocs_File');
}
示例12: upload
public function upload($params = array())
{
if (!is_dir($params['destination_folder'])) {
mkdir($params['destination_folder'], 0777, true);
}
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination($params['destination_folder']);
$adapter->setValidators($params['validators']);
if ($adapter->getValidator('ImageSize')) {
$adapter->getValidator('ImageSize')->setMessages(array('fileImageSizeWidthTooBig' => $this->_('Image too large, %spx maximum allowed.', '%maxwidth%'), 'fileImageSizeWidthTooSmall' => $this->_('Image not large enough, %spx minimum allowed.', '%minwidth%'), 'fileImageSizeHeightTooBig' => $this->_('Image too high, %spx maximum allowed.', '%maxheight%'), 'fileImageSizeHeightTooSmall' => $this->_('Image not high enough, %spx minimum allowed.', '%minheight%'), 'fileImageSizeNotDetected' => $this->_("The image size '%s' could not be detected.", '%value%'), 'fileImageSizeNotReadable' => $this->_("The image '%s' does not exist", '%value%')));
}
if ($adapter->getValidator('Size')) {
$adapter->getValidator('Size')->setMessages(array('fileSizeTooBig' => $this->_("Image too large, '%s' allowed.", '%max%'), 'fileSizeTooSmall' => $this->_("Image not large enough, '%s' allowed.", '%min%'), 'fileSizeNotFound' => $this->_("The image '%s' does not exist", '%value%')));
}
if ($adapter->getValidator('Extension')) {
$adapter->getValidator('Extension')->setMessages(array('fileExtensionFalse' => $this->_("Extension not allowed, '%s' only", '%extension%'), 'fileExtensionNotFound' => $this->_("The file '%s' does not exist", '%value%')));
}
$files = $adapter->getFileInfo();
$return_file = '';
foreach ($files as $file => $info) {
//Créé l'image sur le serveur
if (!$adapter->isUploaded($file)) {
throw new Exception($this->_('An error occurred during process. Please try again later.'));
} else {
if (!$adapter->isValid($file)) {
if (count($adapter->getMessages()) == 1) {
$erreur_message = $this->_('Error : <br/>');
} else {
$erreur_message = $this->_('Errors : <br/>');
}
foreach ($adapter->getMessages() as $message) {
$erreur_message .= '- ' . $message . '<br/>';
}
throw new Exception($erreur_message);
} else {
$new_name = uniqid("file_");
if (isset($params['uniq']) and $params['uniq'] == 1) {
if (isset($params['desired_name'])) {
$new_name = $params['desired_name'];
} else {
$format = pathinfo($info["name"], PATHINFO_EXTENSION);
if (!in_array($format, array("png", "jpg", "jpeg", "gif"))) {
$format = "jpg";
}
$new_name = $params['uniq_prefix'] . uniqid() . ".{$format}";
}
$new_pathname = $params['destination_folder'] . '/' . $new_name;
$adapter->addFilter(new Zend_Filter_File_Rename(array('target' => $new_pathname, 'overwrite' => true)));
}
$adapter->receive($file);
$return_file = $new_name;
}
}
}
return $return_file;
}
示例13: indexAction
public function indexAction()
{
SxCms_Acl::requireAcl('filemanager', 'filemanager.index');
$base = APPLICATION_PATH . '/../public_html/files/';
$base = realpath($base);
$path = base64_decode($this->_getParam('path'));
if ($this->getRequest()->isPost()) {
if (null !== $this->_getParam('folder')) {
SxCms_Acl::requireAcl('filemanager', 'filemanager.add.folder');
if (strlen($this->_getParam('folder'))) {
$dirname = $path . '/' . $this->_getParam('folder');
mkdir($base . $dirname);
$this->_redirect('/admin/filemanager/index/path/' . base64_encode($path));
}
} else {
SxCms_Acl::requireAcl('filemanager', 'filemanager.add.file');
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination(realpath($base) . $path);
if ($adapter->receive()) {
$filename = realpath($adapter->getFileName('filename'));
$file = new SxCms_File($filename);
$path = $file->getPathnameFromBase();
$nfile = $path . '/' . $file->getBasename();
$this->_redirect('/admin/filemanager/edit/file/' . base64_encode($nfile) . '/path/' . base64_encode($path));
} else {
$msg = Sanmax_MessageStack::getInstance('SxCms_Filemanager');
$msg->addMessage('file', $adapter->getMessages());
}
}
}
$this->view->messages = Sanmax_MessageStack::getInstance('SxCms_Filemanager');
try {
$it = new SxCms_Filesystem(realpath($base . $path));
} catch (Exception $e) {
$it = new SxCms_Filesystem($base);
$path = '';
$e;
}
$topdir = explode('/', $path);
if (count($topdir) > 1) {
array_pop($topdir);
$topdir = implode('/', $topdir);
} else {
$topdir = '';
}
$this->view->files = $it;
$this->view->path = $path;
$this->view->showpath = explode('/', $path);
$this->view->topdir = $topdir;
if ($this->_getParam('full')) {
$this->_helper->layout->setLayout('nolayout');
$this->view->full = true;
}
}
示例14: rpsProcessarAction
/**
* Processa os dados do formulário de importação de RPS [json]
*
* @return void
*/
public function rpsProcessarAction()
{
parent::noLayout();
$oForm = new Contribuinte_Form_ImportacaoArquivo();
$oForm->renderizaCamposRPS();
// Adiciona a validação do arquivo junto ao restante das mensagens de erro do form
$aDados = array_merge($this->getRequest()->getPost(), array('isUploaded' => $oForm->arquivo->isUploaded()));
// Valida o formulario e processa a importação
if ($this->getRequest()->isPost() && $oForm->arquivo->isUploaded()) {
$oArquivoUpload = new Zend_File_Transfer_Adapter_Http();
try {
$oArquivoUpload->setDestination(APPLICATION_PATH . '/../public/tmp/');
// Confirma o upload e processa o arquivo
if ($oArquivoUpload->receive()) {
$oImportacaoModelo1 = new Contribuinte_Model_ImportacaoArquivoRpsModelo1();
$oImportacaoModelo1->setArquivoCarregado($oArquivoUpload->getFileName());
$oArquivoCarregado = $oImportacaoModelo1->carregar();
if ($oArquivoCarregado != NULL && $oImportacaoModelo1->validaArquivoCarregado()) {
// Valida as regras de negócio e processa a importação
$oImportacaoProcessamento = new Contribuinte_Model_ImportacaoArquivoProcessamento();
$oImportacaoProcessamento->setCodigoUsuarioLogado($this->usuarioLogado->getId());
$oImportacaoProcessamento->setArquivoCarregado($oArquivoCarregado);
// Processa a importação
$oImportacao = $oImportacaoProcessamento->processarImportacaoRps();
if ($oImportacao->getId()) {
$sUrlRecibo = "/contribuinte/importacao-arquivo/rps-recibo/id/{$oImportacao->getId()}";
$aRetornoJson['status'] = TRUE;
$aRetornoJson['url'] = $this->view->baseUrl($sUrlRecibo);
$aRetornoJson['success'] = $this->translate->_('Arquivo importado com sucesso.');
} else {
throw new Exception($this->translate->_('Ocorreu um erro ao importar o arquivo.'));
}
} else {
throw new Exception($oImportacaoModelo1->processaErroSistema());
}
}
} catch (DBSeller_Exception_ImportacaoXmlException $oErro) {
$aRetornoJson['status'] = FALSE;
$aRetornoJson['error'] = array_merge(array('<b>' . $this->translate->_('Ocorreu um erro ao importar o arquivo:') . '</b><br>'), $oErro->getErrors());
} catch (Exception $oErro) {
$aRetornoJson['status'] = FALSE;
$aRetornoJson['error'][] = $oErro->getMessage();
}
if (is_file($oArquivoUpload->getFileName())) {
unlink($oArquivoUpload->getFileName());
}
} else {
$aRetornoJson['status'] = FALSE;
$aRetornoJson['fields'] = array_keys($oForm->getMessages());
$aRetornoJson['error'][] = $this->translate->_('Preencha os dados corretamente.');
}
echo $this->getHelper('json')->sendJson($aRetornoJson);
}
示例15: UploadFileDatabase
public function UploadFileDatabase($data)
{
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->setDestination(PUBLIC_PATH);
$fileinfo = $adapter->getFileInfo();
$rs = $adapter->receive();
if ($rs == 1) {
return true;
} else {
return false;
}
}