本文整理汇总了PHP中Zend_File_Transfer_Adapter_Http::isReceived方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_File_Transfer_Adapter_Http::isReceived方法的具体用法?PHP Zend_File_Transfer_Adapter_Http::isReceived怎么用?PHP Zend_File_Transfer_Adapter_Http::isReceived使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_File_Transfer_Adapter_Http
的用法示例。
在下文中一共展示了Zend_File_Transfer_Adapter_Http::isReceived方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _uploadFiles
/**
* Handler for files uploader
* @return array
*/
private function _uploadFiles($savePath = null)
{
$this->_uploadHandler->clearValidators();
$this->_uploadHandler->clearFilters();
if (!$savePath) {
$savePath = $this->_getSavePath();
}
$fileInfo = $this->_uploadHandler->getFileInfo();
$file = reset($fileInfo);
preg_match('~[^\\x00-\\x1F"<>\\|:\\*\\?/]+\\.[\\w\\d]{2,8}$~iU', $file['name'], $match);
if (!$match) {
return array('result' => 'Corrupted filename', 'error' => true);
}
$this->_uploadHandler->addFilter('Rename', array('target' => $savePath . DIRECTORY_SEPARATOR . $file['name'], 'overwrite' => true));
if ($this->_uploadHandler->isUploaded() && $this->_uploadHandler->isValid()) {
try {
$this->_uploadHandler->receive();
} catch (Exceptions_SeotoasterException $e) {
$response = array('result' => $e->getMessage(), 'error' => true);
}
}
$response = array('result' => $this->_uploadHandler->getMessages(), 'error' => !$this->_uploadHandler->isReceived());
return $response;
}
示例2: uploadAction
public function uploadAction()
{
$request = $this->getRequest();
$table = new Model_DbTable_Sheets();
$select = $table->select();
$select->where('id = ?', $request->id);
$sheet = $table->fetchRow($select);
if (!$this->view->authenticated || $sheet->user_id != $this->view->identity->id) {
$this->_redirector->gotoRoute(array(), 'login');
}
if ($request->isPost()) {
$path = UPLOAD_PATH . '/sheets/';
if (!file_exists($path)) {
mkdir(str_replace('//', '/', $path), 0755, true);
}
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->setDestination($path);
$upload->addValidators(array(array('Count', false, 5), array('Size', false, '2MB'), array('Extension', false, array('pdf', 'midi', 'mid'))));
if ($upload->isValid()) {
$table = new Model_DbTable_Downloads();
$pattern = array('/-/', '/_/', '/\\s+/');
$replace = array(' - ', ' ', ' ');
foreach ($upload->getFileInfo() as $file => $contents) {
$info = pathinfo($contents['name']);
$row = $table->createRow();
$row->sheet_id = $sheet->id;
$row->type = strtolower($info['extension']) == 'pdf' ? 'PDF' : 'MIDI';
$title = preg_replace($pattern, $replace, $info['filename']);
$row->title = ucwords($title);
$row->save();
$name = $row->id . ($row->type == 'MIDI' ? '.mid' : '.pdf');
$upload->addFilter('Rename', array('target' => $name), $file);
$upload->receive($file);
}
if ($upload->isReceived()) {
return $this->_redirector->gotoRoute(array('controller' => 'sheet', 'id' => $request->id), 'view');
}
}
$this->view->errors = $upload->getMessages();
}
$this->view->headTitle('Upload sheet file(s)');
$this->view->headScript()->appendFile('/js/multifile.js');
$this->view->headScript()->appendFile('/js/upload.js');
$this->view->sheetId = $request->id;
}
示例3: array
<?php
// creating the File_Transfer instance (with Http Adapter)
$upload = new Zend_File_Transfer_Adapter_Http();
// firelog($upload->getFileInfo());
// setting the destination
$UPLOAD_DIR = $_POST['path'];
$upload->setDestination($UPLOAD_DIR);
// adding some validators
//$upload->addValidator('Extension', false, 'csv');*/
// uploading the file if valid
if ($upload->isValid()) {
try {
$upload->addFilter('Rename', array('target' => $UPLOAD_DIR . '/' . $upload->getFileName(null, false)));
$upload->receive();
if ($upload->isReceived()) {
$return = array('success' => true, 'message' => 'SUCESS: ' . $upload->getFileName(null, false) . '(' . $upload->getFileSize() . ')');
} else {
$return = array('success' => false, 'error' => 'ERROR: File Not Received');
}
} catch (Exception $e) {
$return = array('success' => false, 'error' => 'ERROR: Upload Failure');
}
} else {
$return = array('success' => false, 'error' => 'ERROR: File not valid');
}
echo Zend_Json::encode($return);