本文整理汇总了PHP中qqFileUploader::getFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP qqFileUploader::getFilename方法的具体用法?PHP qqFileUploader::getFilename怎么用?PHP qqFileUploader::getFilename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qqFileUploader
的用法示例。
在下文中一共展示了qqFileUploader::getFilename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: admin_add
/**
* Upload attachment
*
* @return void
*/
public function admin_add()
{
$this->set('title_for_layout', __('Add attachment', true));
$allowed_extensions = explode(',', Configure::read('Nodeattachment.allowedFileTypes'));
$size_limit = Configure::read('Nodeattachment.maxFileSize') * 1024 * 1024;
App::import('Vendor', 'Nodeattachment.file-uploader.php');
$uploader = new qqFileUploader($allowed_extensions, $size_limit);
$result = $uploader->handleUpload($this->uploads_path . DS);
$uploader_file_name = $uploader->getFilename();
if (isset($this->params['url']['node_id']) && $uploader_file_name != false) {
$filename['name'] = Inflector::slug($uploader_file_name['filename']);
$filename['ext'] = $uploader_file_name['ext'];
$filename = $this->__uniqeSlugableFilename($filename);
$old_path = $this->uploads_path . DS . $uploader_file_name['filename'] . '.' . $filename['ext'];
$new_path = $this->uploads_path . DS . $filename['name'] . '.' . $filename['ext'];
rename($old_path, $new_path);
$data = array('node_id' => $this->params['url']['node_id'], 'slug' => $filename['name'] . '.' . $filename['ext'], 'path' => '/' . $this->uploads_dir . '/' . $filename['name'] . '.' . $filename['ext'], 'title' => $filename['name'], 'status' => 1, 'mime_type' => $this->__getMime($this->uploads_path . DS . $filename['name'] . '.' . $filename['ext']));
// get shot time of photo
if ($data['mime_type'] == 'image/jpeg' || $data['mime_type'] == 'image/tiff') {
$exif_data = $this->Nodeattachment->getExif($new_path);
if (isset($exif_data['DateTime'])) {
$data['created'] = $exif_data['DateTime'];
}
}
if (!$this->Nodeattachment->save($data)) {
$result = array('error' => __('The Attachment could not be saved. Please, try again.', true));
}
}
Configure::write('debug', 0);
$this->disableCache();
$this->render(false);
echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
}
示例2: admin_add
/**
* Upload attachment
*
* @return void
*/
public function admin_add()
{
$parentNodeId = $this->request->query['node_id'];
$allowedExtensions = explode(',', Configure::read('Nodeattachment.allowedFileTypes'));
$sizeLimit = Configure::read('Nodeattachment.maxFileSize') * 1024 * 1024;
App::import('Vendor', 'Nodeattachment.fileuploader');
$Uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
$result = $Uploader->handleUpload($this->uploads_path . DS);
$uploadedFile = $Uploader->getFilename();
if (isset($parentNodeId) && $uploadedFile != false) {
$fileName = Inflector::slug($uploadedFile['filename']);
$fileName .= '.' . $uploadedFile['ext'];
$fileName = $this->__uniqeSlugableFilename($fileName);
$uploadPath = $this->uploads_path . DS . $uploadedFile['filename'] . '.' . $uploadedFile['ext'];
$newPath = $this->uploads_path . DS . $fileName;
rename($uploadPath, $newPath);
$data = array('node_id' => $parentNodeId, 'slug' => $fileName, 'path' => '/' . $this->uploads_dir . '/' . $fileName, 'title' => $fileName, 'status' => 1, 'mime_type' => $this->__getMime($newPath));
// get shot time of photo
/*if ($data['mime_type'] == 'image/jpeg' || $data['mime_type'] == 'image/tiff') {
$exifData = $this->Nodeattachment->getExif($newPath);
if (isset($exifData['DateTime']))
$data['created'] = $exifData['DateTime'];
}*/
if (!$this->Nodeattachment->save($data)) {
$result = array('success' => false);
}
}
Configure::write('debug', 0);
$this->disableCache();
$this->render(false);
echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
}