本文整理汇总了PHP中file::getInexistantFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP file::getInexistantFilename方法的具体用法?PHP file::getInexistantFilename怎么用?PHP file::getInexistantFilename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::getInexistantFilename方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: act_upload
protected function act_upload()
{
if ($this->config['readonly'] || !isset($this->post['dir'])) {
$this->errorMsg("Unknown error.");
}
$dir = $this->postDir();
if (!dir::isWritable($dir)) {
$this->errorMsg("Cannot access or write to upload folder.");
}
$message = $this->checkUploadedFile();
if ($message !== true) {
if (isset($this->file['tmp_name'])) {
@unlink($this->file['tmp_name']);
}
$this->errorMsg($message);
}
$target = "{$dir}/" . file::getInexistantFilename($this->file['name'], $dir);
if (!move_uploaded_file($this->file['tmp_name'], $target)) {
@unlink($this->file['tmp_name']);
$this->errorMsg("Cannot move uploaded file to target folder.");
} elseif (function_exists('chmod')) {
chmod($target, $this->config['filePerms']);
}
$this->makeThumb($target);
return "/" . basename($target);
}
示例2: moveUploadFile
protected function moveUploadFile($file, $dir)
{
$message = $this->checkUploadedFile($file);
if ($message !== true) {
if (isset($file['tmp_name'])) {
@unlink($file['tmp_name']);
}
return "{$file['name']}: {$message}";
}
// $filename = $this->normalizeFilename($file['name']);
$filename = md5($file['tmp_name']) . '.' . file::getExtension($file['name']);
$target = "{$dir}/" . file::getInexistantFilename($filename, $dir);
if (!@move_uploaded_file($file['tmp_name'], $target) && !@rename($file['tmp_name'], $target) && !@copy($file['tmp_name'], $target)) {
@unlink($file['tmp_name']);
return "{$file['name']}: " . $this->label("Cannot move uploaded file to target folder.");
} elseif (function_exists('chmod')) {
chmod($target, $this->config['filePerms']);
}
$this->makeThumb($target);
return "/" . basename($target);
}
示例3: upload
public function upload()
{
$config =& $this->config;
$file =& $this->file;
$url = $message = "";
if ($config['disabled'] || !$config['access']['files']['upload']) {
if (isset($file['tmp_name'])) {
@unlink($file['tmp_name']);
}
$message = $this->label("You don't have permissions to upload files.");
} elseif (true === ($message = $this->checkUploadedFile())) {
$message = "";
$dir = "{$this->typeDir}/";
if (isset($_GET['dir']) && false !== ($gdir = $this->checkInputDir($_GET['dir']))) {
$udir = path::normalize("{$dir}{$gdir}");
if (substr($udir, 0, strlen($dir)) !== $dir) {
$message = $this->label("Unknown error.");
} else {
$l = strlen($dir);
$dir = "{$udir}/";
$udir = substr($udir, $l);
}
}
if (!strlen($message)) {
if (!is_dir(path::normalize($dir))) {
@mkdir(path::normalize($dir), $this->config['dirPerms'], true);
}
$filename = $this->normalizeFilename($file['name']);
$target = file::getInexistantFilename($dir . $filename);
if (!@move_uploaded_file($file['tmp_name'], $target) && !@rename($file['tmp_name'], $target) && !@copy($file['tmp_name'], $target)) {
$message = $this->label("Cannot move uploaded file to target folder.");
} else {
if (function_exists('chmod')) {
@chmod($target, $this->config['filePerms']);
}
$target = $this->checkUploadedFileMime($target);
// fix the target ...
$this->makeThumb($target);
$url = $this->typeURL;
if (isset($udir)) {
$url .= "/{$udir}";
}
$url .= "/" . basename($target);
if (preg_match('/^([a-z]+)\\:\\/\\/([^\\/^\\:]+)(\\:(\\d+))?\\/(.+)$/', $url, $patt)) {
list($unused, $protocol, $domain, $unused, $port, $path) = $patt;
$base = "{$protocol}://{$domain}" . (strlen($port) ? ":{$port}" : "") . "/";
$url = $base . path::urlPathEncode($path);
} else {
$url = path::urlPathEncode($url);
}
}
}
}
if (strlen($message) && isset($this->file['tmp_name']) && file_exists($this->file['tmp_name'])) {
@unlink($this->file['tmp_name']);
}
if (strlen($message) && method_exists($this, 'errorMsg')) {
$this->errorMsg($message);
} else {
$this->callBack($url, $message);
}
}
示例4: moveUploadFile
protected function moveUploadFile($file, $dir)
{
$message = $this->checkUploadedFile($file);
if ($message !== true) {
if (isset($file['tmp_name'])) {
@unlink($file['tmp_name']);
}
return "{$file['name']}: {$message}";
}
$filename = $this->normalizeFilename($file['name']);
$target = "{$dir}/" . file::getInexistantFilename($filename, $dir);
if (!@move_uploaded_file($file['tmp_name'], $target) && !@rename($file['tmp_name'], $target) && !@copy($file['tmp_name'], $target)) {
@unlink($file['tmp_name']);
return "{$file['name']}: " . $this->label("Cannot move uploaded file to target folder.");
} elseif (function_exists('chmod')) {
chmod($target, $this->config['filePerms']);
}
$this->modx->invokeEvent('OnFileBrowserUpload', array('filepath' => realpath($dir), 'filename' => str_replace("/", "", str_replace($dir, "", realpath($target)))));
$this->makeThumb($target);
return "/" . basename($target);
}
示例5: upload
public function upload()
{
$config =& $this->config;
$file =& $this->file;
$url = $message = "";
if ($config['disabled'] || $config['readonly']) {
if (isset($file['tmp_name'])) {
@unlink($file['tmp_name']);
}
$message = $this->label("You don't have permissions to upload files.");
} elseif (true === ($message = $this->checkUploadedFile())) {
$message = "";
$dir = "{$this->typeDir}/";
if (isset($this->get['dir']) && false !== ($gdir = $this->checkInputDir($this->get['dir']))) {
$udir = path::normalize("{$dir}{$gdir}");
if (substr($udir, 0, strlen($dir)) !== $dir) {
$message = $this->label("Unknown error.");
} else {
$l = strlen($dir);
$dir = "{$udir}/";
$udir = substr($udir, $l);
}
}
if (!strlen($message)) {
if (!is_dir(path::normalize($dir))) {
@mkdir(path::normalize($dir), $this->config['dirPerms'], true);
}
$target = file::getInexistantFilename("{$dir}{$file['name']}");
if (!@move_uploaded_file($file['tmp_name'], $target) && !@rename($file['tmp_name'], $target) && !@copy($file['tmp_name'], $target)) {
$message = $this->label("Cannot move uploaded file to target folder.");
} else {
if (function_exists('chmod')) {
@chmod($target, $this->config['filePerms']);
}
$this->makeThumb($target);
$url = $this->typeURL;
if (isset($udir)) {
$url .= "/{$udir}";
}
$url .= "/" . basename($target);
$url = path::urlPathEncode($url);
}
}
}
if (strlen($message) && isset($this->file['tmp_name']) && file_exists($this->file['tmp_name'])) {
@unlink($this->file['tmp_name']);
}
if (strlen($message) && method_exists($this, 'errorMsg')) {
$this->errorMsg($message);
}
$this->callBack($url, $message);
}
示例6: moveUploadFile
protected function moveUploadFile($file, $dir)
{
$message = $this->checkUploadedFile($file);
if ($message !== true) {
if (isset($file['tmp_name'])) {
@unlink($file['tmp_name']);
}
return "{$file['name']}: {$message}";
}
$filename = $this->normalizeFilename($file['name']);
$target = "{$dir}/" . file::getInexistantFilename($filename, $dir);
if (!@move_uploaded_file($file['tmp_name'], $target) && !@rename($file['tmp_name'], $target) && !@copy($file['tmp_name'], $target)) {
@unlink($file['tmp_name']);
return "{$file['name']}: " . $this->label("Cannot move uploaded file to target folder.");
} elseif (function_exists('chmod')) {
chmod($target, $this->config['filePerms']);
}
$this->makeThumb($target);
if (isset($this->config['extraThumbnails'])) {
foreach ($this->config['extraThumbnails'] as $a) {
// Hack the config values to trick the thumbnail
// creator; FIXME: fork the makeThumb method and
// remove this ugly hack
$this->config['thumbWidth'] = $a['thumbWidth'];
$this->config['thumbHeight'] = $a['thumbHeight'];
// Define the suffix used in file names,
// e.g. DSC82347_300x200.png
$suffix = '_' . $a['thumbWidth'] . 'x' . $a['thumbHeight'];
$this->makeThumb($target, true, $suffix);
}
}
return "/" . basename($target);
}
示例7: upload
public function upload()
{
$config =& $this->config;
$file =& $this->file;
$url = $message = "";
if ($config['disabled'] || !$config['access']['files']['upload']) {
if (isset($file['tmp_name'])) {
@unlink($file['tmp_name']);
}
$message = $this->label("You don't have permissions to upload files.");
} elseif (true === ($message = $this->checkUploadedFile())) {
$message = "";
$dir = "{$this->typeDir}/";
if (isset($this->get['dir']) && false !== ($gdir = $this->checkInputDir($this->get['dir']))) {
$udir = path::normalize("{$dir}{$gdir}");
if (substr($udir, 0, strlen($dir)) !== $dir) {
$message = $this->label("Unknown error.");
} else {
$l = strlen($dir);
$dir = "{$udir}/";
$udir = substr($udir, $l);
}
}
if (!strlen($message)) {
if (!is_dir(path::normalize($dir))) {
@mkdir(path::normalize($dir), $this->config['dirPerms'], true);
}
$filename = $this->normalizeFilename($file['name']);
$target = file::getInexistantFilename($dir . $filename);
if (!@move_uploaded_file($file['tmp_name'], $target) && !@rename($file['tmp_name'], $target) && !@copy($file['tmp_name'], $target)) {
$message = $this->label("Cannot move uploaded file to target folder.");
} else {
if (function_exists('chmod')) {
@chmod($target, $this->config['filePerms']);
}
$this->makeThumb($target);
if (isset($this->config['extraThumbnails'])) {
die('entered!');
foreach ($this->config['extraThumbnails'] as $a) {
// Hack the config values to trick the thumbnail
// creator; FIXME: fork the makeThumb method and
// remove this ugly hack
$this->config['thumbWidth'] = $a['thumbWidth'];
$this->config['thumbHeight'] = $a['thumbHeight'];
// Define the suffix used in file names,
// e.g. DSC82347_300x200.png
$suffix = '_' . $a['thumbWidth'] . 'x' . $a['thumbHeight'];
$this->makeThumb($target, true, $suffix);
}
}
if ($this->config['read_exif'] == true) {
$exif = exif_read_data($target, 'IFD0');
file_put_contents(json_encode($exif), '/tmp/exif');
}
$url = $this->typeURL;
if (isset($udir)) {
$url .= "/{$udir}";
}
$url .= "/" . basename($target);
if (preg_match('/^([a-z]+)\\:\\/\\/([^\\/^\\:]+)(\\:(\\d+))?\\/(.+)$/', $url, $patt)) {
list($unused, $protocol, $domain, $unused, $port, $path) = $patt;
$base = "{$protocol}://{$domain}" . (strlen($port) ? ":{$port}" : "") . "/";
$url = $base . path::urlPathEncode($path);
} else {
$url = path::urlPathEncode($url);
}
}
}
}
if (strlen($message) && isset($this->file['tmp_name']) && file_exists($this->file['tmp_name'])) {
@unlink($this->file['tmp_name']);
}
if (strlen($message) && method_exists($this, 'errorMsg')) {
$this->errorMsg($message);
}
$this->callBack($url, $message);
}