本文整理汇总了PHP中Zend_File_Transfer_Adapter_Http类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_File_Transfer_Adapter_Http类的具体用法?PHP Zend_File_Transfer_Adapter_Http怎么用?PHP Zend_File_Transfer_Adapter_Http使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_File_Transfer_Adapter_Http类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
}
}
示例2: 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);
}
示例3: 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');
}
}
示例4: handleUploadedFile
/**
* Handle the uploaded file
*
* @return string|boolean
*/
public function handleUploadedFile()
{
$upload = new Zend_File_Transfer_Adapter_Http();
$target = $this->getTargetFilename($upload->getFilename());
$upload->addFilter(new Zend_Filter_File_Rename(array('target' => $target)));
return $upload->receive() ? $target : false;
}
示例5: handleUpload
/**
* @param string $attributeCode
* @param string $type
* @return bool
*/
protected static function handleUpload($attributeCode, $type)
{
if (!isset($_FILES)) {
return false;
}
$adapter = new Zend_File_Transfer_Adapter_Http();
if ($adapter->isUploaded('typecms_' . $attributeCode . '_')) {
if (!$adapter->isValid('typecms_' . $attributeCode . '_')) {
Mage::throwException(Mage::helper('typecms')->__('Uploaded ' . $type . ' is invalid'));
}
$upload = new Varien_File_Uploader('typecms[' . $attributeCode . ']');
$upload->setAllowCreateFolders(true);
if ($type == 'image') {
$upload->setAllowedExtensions(array('jpg', 'gif', 'png'));
}
$upload->setAllowRenameFiles(true);
$upload->setFilesDispersion(false);
try {
if ($upload->save(Mage::helper('typecms')->getBaseImageDir())) {
return $upload->getUploadedFileName();
}
} catch (Exception $e) {
Mage::throwException('Uploaded ' . $type . ' is invalid');
}
}
return false;
}
示例6: uploadImage
public function uploadImage($scope)
{
// create an instance of class Zend_File_Transfer_Adapter_Http
// and add validator
$adapter = new Zend_File_Transfer_Adapter_Http();
$adapter->addValidator('ImageSize', true, $this->_imageSize);
$adapter->addValidator('Size', true, self::MAX_FILE_SIZE);
// if image can be uploaded
if ($adapter->isUploaded($scope)) {
//validate image
if (!$adapter->isValid($scope)) {
Mage::throwException(Mage::helper('ab_adverboard')->__('Uploaded image is not valid'));
}
// upload image
$upload = new Varien_File_Uploader($scope);
$upload->setAllowCreateFolders(true);
$upload->setAllowedExtensions($this->_allowedExtensions);
$upload->setAllowRenameFiles(false);
$upload->setFilesDispersion(false);
if ($upload->save($this->getBaseDir(), $_FILES['image']['name'])) {
return $upload->getUploadedFileName();
}
}
return false;
}
示例7: 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");
}
}
示例8: signupAction
public function signupAction()
{
$users = new Application_Model_User();
$form = new Application_Form_Registration();
$this->view->form = $form;
// Define a transport and set the destination on the server
// $upload = new Zend_File_Transfer_Adapter_Http();
// $upload->addFilter('Rename', APPLICATION_PATH . '/../data/'.'jpg');
// $upload->addFilter('Rename', APPLICATION_PATH . '/../data/');
// Zend_Debug::dump($upload->getFileInfo());
if ($this->getRequest()->isPost()) {
if ($form->isValid($_POST)) {
// $upload->setDestination('data/');
//
// $upload->receive();
$data = $form->getValues();
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->receive();
if ($data['password'] != $data['confirmPassword']) {
$this->view->errorMessage = "Password and confirm password don't match.";
return;
}
if ($users->checkUnique($data['name'])) {
$this->view->errorMessage = "Name already taken. Please choose another one.";
return;
}
unset($data['confirmPassword']);
$users->insert($data);
echo 'tmaaaaaaaam';
$this->_redirect('auth/login');
echo 'tmaaaaaaaam';
}
}
}
示例9: 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;
}
}
示例10: 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");
}
示例11: 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);
}
示例12: 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);
}
}
示例13: 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');
}
示例14: uploadAction
/**
* upload
*/
public function uploadAction()
{
// disable layouts for this action:
$this->_helper->layout->disableLayout();
if ($this->_request->isPost()) {
try {
$destination = PUBLIC_PATH . "/uploads/files";
/* Check destination folder */
if (!is_dir($destination)) {
if (is_writable(PUBLIC_PATH . "/uploads")) {
mkdir($destination);
} else {
throw new Exception("Uploads directory is not writable");
}
}
/* Uploading Document File on Server */
$upload = new Zend_File_Transfer_Adapter_Http();
try {
// upload received file(s)
$upload->receive();
} catch (Zend_File_Transfer_Exception $e) {
$e->getMessage();
}
// you MUST use following functions for knowing about uploaded file
// Returns the file name for 'doc_path' named file element
$filePath = $upload->getFileName('file');
// pathinfo
$name = pathinfo($filePath, PATHINFO_FILENAME);
$ext = pathinfo($filePath, PATHINFO_EXTENSION);
// prepare filename
$name = strtolower($name);
$name = preg_replace('/[^a-z0-9_-]/', '-', $name);
// prepare extension
if ($ext == 'php' or $ext == 'php4' or $ext == 'php5' or $ext == 'phtml') {
$ext = 'phps';
}
// rename uploaded file
$renameFile = $name . '.' . $ext;
$counter = 0;
while (file_exists($destination . '/' . $renameFile)) {
$counter++;
$renameFile = $name . '-' . $counter . '.' . $ext;
}
$fileIco = $this->getIco($ext);
$fullFilePath = $destination . '/' . $renameFile;
// Rename uploaded file using Zend Framework
$filterFileRename = new Zend_Filter_File_Rename(array('target' => $fullFilePath, 'overwrite' => true));
$filterFileRename->filter($filePath);
$this->_helper->viewRenderer->setNoRender(true);
$link = '<a href="javascript:void(null);" rel="' . $renameFile . '" class="redactor_file_link redactor_file_ico_' . $fileIco . '" title="' . $renameFile . '">' . $renameFile . '</a>';
echo $link;
} catch (Exception $e) {
$this->_forwardError($e->getMessage());
}
} else {
$this->_forwardError('Internal Error of Uploads controller');
}
}
示例15: 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