本文整理汇总了PHP中Zend_File_Transfer_Adapter_Http::receive方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_File_Transfer_Adapter_Http::receive方法的具体用法?PHP Zend_File_Transfer_Adapter_Http::receive怎么用?PHP Zend_File_Transfer_Adapter_Http::receive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_File_Transfer_Adapter_Http
的用法示例。
在下文中一共展示了Zend_File_Transfer_Adapter_Http::receive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _transferFile
/**
* Use the Zend_File_Transfer adapter to upload the file.
*
* @internal The resulting filename is retrieved via the adapter's
* getFileName() method.
*
* @param array $fileInfo
* @param string $originalFilename
* @return string Path to the file in Omeka.
*/
protected function _transferFile($fileInfo, $originalFilename)
{
// Upload a single file at a time.
if (!$this->_adapter->receive($fileInfo['form_index'])) {
throw new Omeka_File_Ingest_InvalidException(join("\n\n", $this->_adapter->getMessages()));
}
// Return the path to the file as it is listed in Omeka.
return $this->_adapter->getFileName($fileInfo['form_index']);
}
示例2: 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';
}
}
}
示例3: 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");
}
}
示例4: 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);
}
示例5: 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;
}
示例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: 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: 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);
}
}
示例9: 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);
}
示例10: 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');
}
}
示例11: 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');
}
}
}
示例12: 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());
}
}
}
示例13: 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>';
}
}
}
}
示例14: 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');
}
示例15: 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');
}
}