本文整理汇总了PHP中Zend_File_Transfer_Adapter_Http::getFileInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_File_Transfer_Adapter_Http::getFileInfo方法的具体用法?PHP Zend_File_Transfer_Adapter_Http::getFileInfo怎么用?PHP Zend_File_Transfer_Adapter_Http::getFileInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_File_Transfer_Adapter_Http
的用法示例。
在下文中一共展示了Zend_File_Transfer_Adapter_Http::getFileInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createAction
public function createAction()
{
parent::postDispatch();
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity()) {
$this->redirect('/auth');
}
$dbTable = new Application_Model_DbTable_Block();
$adapter = new Zend_File_Transfer_Adapter_Http();
$options = array('ignoreNoFile' => true);
$adapter->setOptions($options);
$info = $adapter->getFileInfo();
// Redireciona para home depois do submit
if (isset($_POST['submit'])) {
//Envia para a tabela um novo bloco criada.
$adapter->setDestination('c:/teste');
$link_file = $adapter->getFileName();
$name_file = $adapter->getFileName(null, false);
$text = $_POST['text'];
$author = $_POST['author'];
$type = $_POST['type'];
$dbTable->insert(array('date' => date('Y-m-d H:i:s'), 'text' => "{$text}", 'type' => "{$type}"));
$adapter->receive();
header('Location: ../');
}
}
示例2: uploadAction
public function uploadAction()
{
$project_id = $this->_request->getParam('id');
//Validate that project belongs to user here.
$project_helper = $this->_helper->Projects;
if ($project_helper->isOwner($this->user_session->id, $project_id, $this->project_model)) {
$adapter = new Zend_File_Transfer_Adapter_Http();
foreach ($adapter->getFileInfo() as $key => $file) {
//Get extension
$path = split("[/\\.]", $file['name']);
$ext = end($path);
try {
$adapter->addValidator('Extension', false, array('extension' => 'jpg,gif,png', 'case' => true));
//Should probably use the array method below to enable overwriting
$new_name = md5(rand()) . '-' . $project_id . '.' . $ext;
//Add rename filter
$adapter->addFilter('Rename', UPLOAD_PATH . $new_name);
} catch (Zend_File_Transfer_Exception $e) {
die($e->getMessage());
}
try {
//Store
if ($adapter->receive($file['name'])) {
$this->image_model->addOne($project_id, $new_name, $key);
}
} catch (Zend_File_Transfer_Exception $e) {
die($e->getMessage());
}
}
header("Location: /account/project/id/{$project_id}");
} else {
header("Location: /account");
}
}
示例3: bulkuploadAction
/**
* Bulk product upload functinality for seller
*
* @return void
*/
public function bulkuploadAction()
{
/**
* Check license key
*/
Mage::helper('marketplace')->checkMarketplaceKey();
/**
* Check whether seller or not
*/
$this->checkWhetherSellerOrNot();
try {
/**
* New zend File Uploader
*/
$uploadsData = new Zend_File_Transfer_Adapter_Http();
$filesDataArray = $uploadsData->getFileInfo();
/**
* Checking whether csv exist or not
*/
if (!empty($filesDataArray)) {
$this->saveBulkUploadFiles($filesDataArray);
}
} catch (Exception $e) {
/**
* Display error message for csv file upload
*/
Mage::getSingleton('core/session')->addError($this->__($e->getMessage()));
$this->_redirect('marketplace/product/manage');
return;
}
}
示例4: 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);
}
示例5: 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);
}
示例6: 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());
}
}
}
示例7: 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');
}
}
示例8: 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');
}
}
}
示例9: 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');
}
}
示例10: 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>';
}
}
}
}
示例11: saveProviderAction
public function saveProviderAction($providerId, Form_GenericProviderConfiguration $form, $action, $actionType)
{
$actionObject = null;
$contentDistributionPlugin = Kaltura_Client_ContentDistribution_Plugin::get($this->client);
try {
$actionObject = $contentDistributionPlugin->genericDistributionProviderAction->getByProviderId($providerId, $actionType);
} catch (Exception $e) {
}
$isNew = true;
if ($actionObject) {
$isNew = false;
} else {
$actionObject = new Kaltura_Client_ContentDistribution_Type_GenericDistributionProviderAction();
$actionObject->genericDistributionProviderId = $providerId;
$actionObject->action = $actionType;
}
$actionObject = $form->getActionObject($actionObject, $action, $actionType);
if (!$actionObject) {
if (!$isNew) {
$contentDistributionPlugin->genericDistributionProviderAction->deleteByProviderId($providerId, $actionType);
}
return;
}
$genericDistributionProviderAction = null;
if ($isNew) {
$genericDistributionProviderAction = $contentDistributionPlugin->genericDistributionProviderAction->add($actionObject);
} else {
// reset all readonly fields
$actionObject->id = null;
$actionObject->createdAt = null;
$actionObject->updatedAt = null;
$actionObject->genericDistributionProviderId = null;
$actionObject->action = null;
$actionObject->status = null;
$actionObject->mrssTransformer = null;
$actionObject->mrssValidator = null;
$actionObject->resultsTransformer = null;
$genericDistributionProviderAction = $contentDistributionPlugin->genericDistributionProviderAction->updateByProviderId($providerId, $actionType, $actionObject);
}
$genericDistributionProviderActionId = $genericDistributionProviderAction->id;
$upload = new Zend_File_Transfer_Adapter_Http();
$files = $upload->getFileInfo();
if (count($files)) {
if (isset($files["mrssTransformer{$action}"]) && $files["mrssTransformer{$action}"]['size']) {
$file = $files["mrssTransformer{$action}"];
$contentDistributionPlugin->genericDistributionProviderAction->addMrssTransformFromFile($genericDistributionProviderActionId, $file['tmp_name']);
}
if (isset($files["mrssValidator{$action}"]) && $files["mrssValidator{$action}"]['size']) {
$file = $files["mrssValidator{$action}"];
$contentDistributionPlugin->genericDistributionProviderAction->addMrssValidateFromFile($genericDistributionProviderActionId, $file['tmp_name']);
}
if (isset($files["resultsTransformer{$action}"]) && $files["resultsTransformer{$action}"]['size']) {
$file = $files["resultsTransformer{$action}"];
$contentDistributionPlugin->genericDistributionProviderAction->addResultsTransformFromFile($genericDistributionProviderActionId, $file['tmp_name']);
}
}
}
开发者ID:EfncoPlugins,项目名称:Media-Management-based-on-Kaltura,代码行数:57,代码来源:GenericDistributionProviderConfigureAction.php
示例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: getObject
public function getObject($objectType, array $properties, $add_underscore = true, $include_empty_fields = false)
{
$object = parent::getObject($objectType, $properties, $add_underscore, $include_empty_fields);
$upload = new Zend_File_Transfer_Adapter_Http();
$files = $upload->getFileInfo();
if (count($files) && isset($files["xslfile"]) && $files["xslfile"]['size']) {
$object->xsl = file_get_contents($files["xslfile"]['tmp_name']);
}
return $object;
}
示例14: getObject
public function getObject($objectType, array $properties, $add_underscore = true, $include_empty_fields = false)
{
/* @var $object Kaltura_Client_FtpDistribution_Type_FtpDistributionProfile */
$object = parent::getObject($objectType, $properties, $add_underscore, true);
$upload = new Zend_File_Transfer_Adapter_Http();
$files = $upload->getFileInfo();
if (isset($files['sftp_public_key'])) {
$object->sftpPublicKey = $this->getFileContent($files['sftp_public_key']);
}
if (isset($files['sftp_private_key'])) {
$object->sftpPrivateKey = $this->getFileContent($files['sftp_private_key']);
}
if (isset($files['aspera_public_key'])) {
$object->asperaPublicKey = $this->getFileContent($files['aspera_public_key']);
}
if (isset($files['aspera_private_key'])) {
$object->asperaPrivateKey = $this->getFileContent($files['aspera_private_key']);
}
$updateRequiredEntryFields = array();
$updateRequiredMetadataXpaths = array();
$entryFields = array_keys($this->getEntryFields());
$metadataXpaths = array_keys($this->getMetadataFields());
$fieldConfigArray = $object->fieldConfigArray;
foreach ($properties as $property => $value) {
if (!$value) {
continue;
}
$updateField = null;
$matches = null;
if (preg_match('/update_required_entry_fields_(\\d+)$/', $property, $matches)) {
$index = $matches[1];
if (isset($entryFields[$index])) {
$updateField = $entryFields[$index];
}
}
if (preg_match('/update_required_metadata_xpaths_(\\d+)$/', $property, $matches)) {
$index = $matches[1];
if (isset($metadataXpaths[$index])) {
$updateField = $metadataXpaths[$index];
}
}
if ($updateField) {
$fieldConfig = new Kaltura_Client_ContentDistribution_Type_DistributionFieldConfig();
$fieldConfig->fieldName = md5($updateField);
// needs to have a value for the field to get saved
$fieldConfig->updateOnChange = true;
$string = new Kaltura_Client_Type_String();
$string->value = $updateField;
$fieldConfig->updateParams = array($string);
$fieldConfigArray[] = $fieldConfig;
}
}
$object->fieldConfigArray = $fieldConfigArray;
return $object;
}
示例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;
}
}