本文整理汇总了PHP中getFileName函数的典型用法代码示例。如果您正苦于以下问题:PHP getFileName函数的具体用法?PHP getFileName怎么用?PHP getFileName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getFileName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doUpload
function doUpload(&$drive_service, &$client, &$file, &$parentFolderID, &$configObj)
{
//Chunk size is in bytes
//Currently, resumable upload uses chunks of 1000 bytes
$chunk_size = 1000;
//doUpload with exponential backoff, five tries
for ($n = 0; $n < 5; ++$n) {
try {
//Choose between media and resumable depending on file size
if ($file->size > $chunk_size) {
insertFileResumable($drive_service, &$client, getFileName($file->path), "", $parentFolderID, $file->type, $file->path, $configObj);
} else {
insertFileMedia($drive_service, getFileName($file->path), "", $parentFolderID, $file->type, $file->path, $configObj);
}
//If upload succeeded, return null
return;
} catch (Google_Exception $e) {
if ($e->getCode() == 403 || $e->getCode() == 503) {
$logline = date('Y-m-d H:i:s') . " Error: " . $e->getMessage() . "\n";
$logline = $logline . date('Y-m-d H:i:s') . "Retrying... \n";
fwrite($configObj->logFile, $logline);
// Apply exponential backoff.
usleep((1 << $n) * 1000000 + rand(0, 1000000));
}
} catch (Exception $e) {
$logline = date('Y-m-d H:i:s') . ": Unable to upload file.\n";
$logline = $logline . "Reason: " . $e->getCode() . " : " . $e->getMessage() . "\n";
fwrite($configObj->logFile, $logline);
//If upload failed because of unrecognized error, return the file
return $file;
}
}
//If upload failed, return the file
return $file;
}
示例2: initialize_page
function initialize_page()
{
$post_action = "";
if (isset($_POST['submit'])) {
$post_action = $_POST['submit'];
}
if ($post_action == "Add Document" || $post_action == "Add and Return to List") {
$name = $_POST['name'];
$file_type = getFileExtension($_FILES['file']['name']);
$filename = slug(getFileName($_FILES['file']['name']));
$filename_string = $filename . "." . $file_type;
// Check to make sure there isn't already a file with that name
$possibledoc = Documents::FindByFilename($filename_string);
if (is_object($possibledoc)) {
setFlash("<h3>Failure: Document filename already exists!</h3>");
redirect("admin/add_document");
}
$target_path = SERVER_DOCUMENTS_ROOT . $filename_string;
if (move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
$new_doc = MyActiveRecord::Create('Documents', array('name' => $name, 'filename' => $filename_string, 'file_type' => $file_type));
$new_doc->save();
if (!chmod($target_path, 0644)) {
setFlash("<h3>Warning: Document Permissions not set; this file may not display properly</h3>");
}
setFlash("<h3>Document uploaded</h3>");
} else {
setFlash("<h3>Failure: Document could not be uploaded</h3>");
}
if ($post_action == "Add and Return to List") {
redirect("admin/list_documents");
}
}
}
示例3: upload
public static function upload(UploadedFile $file, $uploadPath = null)
{
if (is_null($uploadPath)) {
$uploadPath = public_path() . '/uploads/';
}
$fileName = str_slug(getFileName($file->getClientOriginalName())) . '.' . $file->getClientOriginalExtension();
//Make file name unique so it doesn't overwrite any old photos
while (file_exists($uploadPath . $fileName)) {
$fileName = str_slug(getFileName($file->getClientOriginalName())) . '-' . str_random(5) . '.' . $file->getClientOriginalExtension();
}
$file->move($uploadPath, $fileName);
return ['filename' => $fileName, 'fullpath' => $uploadPath . $fileName];
}
示例4: loadClass
function loadClass($className)
{
global $CONFIG;
if (0 == strpos($className, 'Twig')) {
$file = $CONFIG['CENTRAL_PATH'] . 'vendor/Twig/lib/' . str_replace(array('_', ""), array('/', ''), $className) . '.php';
if (is_file($file)) {
require $file;
return;
}
}
$fileName = getFileName($className);
require getFullPath($fileName);
}
示例5: move
function move($path, $filename, $newname = null)
{
$allowed = array('jpg', 'jpeg', 'pdf', 'png', 'xls', 'xlsx', 'zip');
if (file_exists($_FILES[$filename]['tmp_name'])) {
if (in_array(getFileExtension(getFileName($filename)), $allowed) && $_FILES[$filename]['error'] == 0) {
$uploadname = isset($newname) ? $newname : getFileName($filename);
try {
move_uploaded_file($_FILES[$filename]['tmp_name'], $path . $uploadname);
} catch (Exception $e) {
echo "Error Occurred Uploading File: " . $e->getMessage();
}
}
} else {
throw new Exception('FILE NOT FOUND');
}
}
示例6: form
function form($name = '', $desc = '', $screen = -1, $idn = 0)
{
?>
<script type="text/javascript" src="admin/files.js"> </script>
<form action="<?php
echo htmlentities($_SERVER['REQUEST_URI']);
?>
" method="post" id="form">
<label for="shot_name">Name:</label>
<input type="text" maxlength="100" size=70 name="shot_name" id="shot_name"<?php
echo !empty($name) ? " value=\"{$name}\"" : '';
?>
/><br />
<label for="shot_desc">Description:</label>
<input type="text" maxlength="255" size=100 name="shot_desc" id="shot_desc"<?php
echo !empty($desc) ? " value=\"{$desc}\"" : '';
?>
/><br />
<label for="shot_screen_disp">Screenshot:</label>
<input type="text" name="shot_screen_disp" readonly=true size=60 id="shot_screen_disp" value="<?php
echo htmlentities(stripslashes(getFileName($screen)));
?>
" />
<input type="hidden" name="shot_screen" id="shot_screen" value="<?php
echo getFileID($screen);
?>
" /><br />
<input type="button" onclick="javascript:switchVisibility('shot_screen',-1)" value='Pick a file' /><br />
<div id="shot_screen_div" style="display: none;">
<iframe src="" id="shot_screen_frame" width=600 ></iframe>
</div><br />
<?php
if ($idn != 0) {
?>
<input type="hidden" name="id" value="<?php
echo $idn;
?>
" />
<?php
}
?>
<input type="submit" />
</form>
<?php
}
示例7: devtips_extract
function devtips_extract(DevTip $tip)
{
global $updates_dir;
$assetPath = getFileName($tip->get('date'), $tip->get('title'));
$assetPath = str_replace(".markdown", "", $assetPath);
# create new asset directory based on new filename
if (!file_exists($updates_dir . 'images/' . $assetPath)) {
mkdir($updates_dir . 'images/' . $assetPath);
chmod($updates_dir . 'images/' . $assetPath, 0777);
}
# Download and store each asset
$assets = $tip->get('assets');
$featured = null;
foreach ($assets as $key => $url) {
if (strpos($url, "/sponsor/") !== false) {
continue;
}
$base = new Net_URL2('https://umaar.com/dev-tips/');
$abs = $base->resolve($url);
$dest = $updates_dir . 'images/' . $assetPath . '/' . pathinfo($url)['basename'];
$content = $tip->get('content');
$tip->set('content', str_replace($url, '/web/updates/images/' . $assetPath . '/' . pathinfo($url)['basename'], $content));
if (!$featured) {
$tip->set('featured-image', '/web/updates/images/' . $assetPath . '/' . pathinfo($url)['basename']);
}
if (!file_exists($dest)) {
set_time_limit(0);
$fp = fopen($dest, 'w+');
//This is the file where we save the information
$ch = curl_init(str_replace(" ", "%20", $abs));
//Here is the file we are downloading, replace spaces with %20
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_FILE, $fp);
// write curl response to file
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
// get curl response
curl_close($ch);
fclose($fp);
// set proper chmod
chmod($dest, 0777);
}
}
}
示例8: form
function form($name = '', $desc = '', $author = '', $version = '', $platform = '', $requires = '', $screen = -1, $file = -1, $idn = -1)
{
?>
<script type="text/javascript" src="admin/files.js"> </script>
<form action="<?php
echo htmlentities($_SERVER['REQUEST_URI']);
?>
" method="post" id="form">
<label for="plugin_name">Name:</label>
<input type="text" maxlength="100" size=70 name="plugin_name" id="plugin_name"<?php
echo !empty($name) ? " value=\"{$name}\"" : '';
?>
/><br />
<label for="plugin_desc">Description:</label>
<input type="text" maxlength="255" size=100 name="plugin_desc" id="plugin_desc"<?php
echo !empty($desc) ? " value=\"{$desc}\"" : '';
?>
/><br />
<label for="plugin_author">Author:</label>
<input type="text" maxlength="100" name="plugin_author" id="plugin_author"<?php
echo !empty($author) ? " value=\"{$author}\"" : '';
?>
/><br />
<label for="plugin_version">Version:</label>
<input type="text" maxlength="20" name="plugin_version" id="plugin_version"<?php
echo !empty($version) ? " value=\"{$version}\"" : '';
?>
/><br />
<label for="plugin_platform">Platform/OS:</label>
<input type="text" maxlength="50" name="plugin_platform" id="plugin_platform"<?php
echo !empty($platform) ? " value=\"{$platform}\"" : '';
?>
/><br />
<label for="plugin_requires">Requires:</label>
<input type="text" maxlength="50" name="plugin_requires" id="plugin_requires"<?php
echo !empty($requires) ? " value=\"{$requires}\"" : '';
?>
/><br />
<label for="plugin_screen_disp">Screenshot:</label>
<input type="text" name="plugin_screen_disp" readonly=true size=60 id="plugin_screen_disp" value="<?php
echo htmlentities(stripslashes(getFileName($screen)));
?>
" />
<input type="hidden" name="plugin_screen" id="plugin_screen" value="<?php
echo getFileID($screen);
?>
" /><br />
<input type="button" onclick="javascript:switchVisibility('plugin_screen',-1)" value='Pick a file' /><br />
<div id="plugin_screen_div" style="display: none;">
<iframe src="" id="plugin_screen_frame" width=600 ></iframe>
</div><br />
<label for="plugin_file_disp">File:</label>
<input type="text" name="plugin_file_disp" readonly=true size=60 id="plugin_file_disp" value="<?php
echo htmlentities(stripslashes(getFileName($file)));
?>
" />
<input type="hidden" name="plugin_file" id="plugin_file" value="<?php
echo getFileID($file);
?>
" /><br />
<input type="button" onclick="javascript:switchVisibility('plugin_file',-1)" value='Pick a file' /><br />
<div id="plugin_file_div" style="display: none;">
<iframe src="" id="plugin_file_frame" width=600 ></iframe>
</div><br />
<?php
if ($idn != 0) {
?>
<input type="hidden" name="id" value="<?php
echo $idn;
?>
" />
<?php
}
?>
<input type="submit" />
</form>
<?php
}
示例9: foreach
}
}
}
}
$zskkey = false;
$kskkey = false;
foreach ($zone['sec'] as $sec) {
$dir = "/srv/bind/dnssec/" . $zone['soa']['origin'] . "/";
if (!file_exists($dir)) {
shell_exec("mkdir -p " . $dir);
}
if ($sec['type'] == "ZSK" || $sec['type'] == "KSK") {
if (!empty($sec['public']) && !empty($sec['private'])) {
preg_match("/; This is a (key|zone)-signing key, keyid ([0-9]+), for " . $zone['soa']['origin'] . "/i", $sec['public'], $match);
$filename1 = getFileName($zone['soa']['origin'], $sec['algo'], $match[2], "pub");
$filename2 = getFileName($zone['soa']['origin'], $sec['algo'], $match[2], "priv");
if (file_exists($dir . $filename1)) {
unlink($dir . $filename1);
}
if (file_exists($dir . $filename2)) {
unlink($dir . $filename2);
}
$handler = fOpen($dir . $filename1, "a+");
fWrite($handler, $sec['public']);
fClose($handler);
$handler = fOpen($dir . $filename2, "a+");
fWrite($handler, $sec['private']);
fClose($handler);
if (file_exists($dir . $filename1) && file_exists($dir . $filename2)) {
/* fallback for missing DNSKEY record */
if ($zsk === false || $ksk === false) {
示例10: clone_page
/**
* Clone a page
* Automatically names page id to next incremental copy eg. "slug-n"
* Clone title becomes "title [copy]""
*
* @param str $id page id to clone
* @return mixed returns new url on succcess, bool false on failure
*/
function clone_page($id)
{
list($cloneurl, $count) = getNextFileName(GSDATAPAGESPATH, $id . '.xml');
// get page and resave with new slug and title
$newxml = getPageXML($id);
$newurl = getFileName($cloneurl);
$newxml->url = getFileName($cloneurl);
$newxml->title = $newxml->title . ' [' . sprintf(i18n_r('COPY_N', i18n_r('COPY')), $count) . ']';
$newxml->pubDate = date('r');
$status = XMLsave($newxml, GSDATAPAGESPATH . $cloneurl);
if ($status) {
return $newurl;
}
return false;
}
示例11: elseif
</table></p>
<?php
} elseif ($_GET['action'] == 'clean') {
$q = @mysql_query("SELECT * FROM `amsn_files` ORDER BY `filename`, `url`");
while ($row = mysql_fetch_assoc($q)) {
$count = 0;
$count = $count + mysql_num_rows(@mysql_query("SELECT id FROM `amsn_skins` WHERE screen_id={$row['id']} OR file_id={$row['id']};"));
$count = $count + mysql_num_rows(@mysql_query("SELECT id FROM `amsn_plugins` WHERE screen_id={$row['id']} OR file_id={$row['id']};"));
$count = $count + mysql_num_rows(@mysql_query("SELECT id FROM `amsn_screenshots` WHERE screen_id={$row['id']};"));
if ($count == 0) {
if ($row['filename'] != '') {
unlink(getFilePath($row['filename']));
}
echo "<p>Removing the file " . getFileName($row['id']) . " from the database</p>\n";
if (!mysql_query("DELETE FROM `amsn_files` WHERE id = '" . $row['id'] . "' LIMIT 1")) {
echo "<p>There was an error when trying to remove the file " . getFileName($row['id']) . " from the database</p>\n";
}
}
}
} elseif ($_GET['action'] == 'edit') {
if (!mysql_num_rows($q = mysql_query("SELECT * FROM `amsn_files` ORDER BY `filename`, `url`"))) {
echo "<p>There are no files yet</p>\n";
return;
}
if (isset($_POST['id']) && ereg('^[1-9][0-9]*$', $_POST['id']) && !mysql_num_rows($q = @mysql_query("SELECT * FROM `amsn_files` WHERE id = '" . (int) $_POST['id'] . "' LIMIT 1"))) {
echo "<p>The selected item don't exists</p>\n";
return;
}
if ($_GET['action'] == 'edit' && isset($_POST['id'])) {
if (isset($_POST['id'], $_POST['type'])) {
$_POST = clean4sql($_POST);
示例12: sendFile
function sendFile($filename, $contentType = null, $nameToSent = null, $mustExit = true)
{
global $canUseXSendFile;
$stat = @LFS::stat($filename);
if ($stat && @LFS::is_file($filename) && @LFS::is_readable($filename)) {
$etag = sprintf('"%x-%x-%x"', $stat['ino'], $stat['size'], $stat['mtime'] * 1000000);
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] == $etag || isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $stat['mtime']) {
header('HTTP/1.0 304 Not Modified');
} else {
header('Content-Type: ' . (is_null($contentType) ? 'application/octet-stream' : $contentType));
if (is_null($nameToSent)) {
$nameToSent = getFileName($filename);
}
if (isset($_SERVER['HTTP_USER_AGENT']) && strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
$nameToSent = rawurlencode($nameToSent);
}
header('Content-Disposition: attachment; filename="' . $nameToSent . '"');
if ($mustExit && $canUseXSendFile && function_exists('apache_get_modules') && in_array('mod_xsendfile', apache_get_modules())) {
header("X-Sendfile: " . $filename);
} else {
header('Cache-Control: ');
header('Expires: ');
header('Pragma: ');
header('Etag: ' . $etag);
header('Last-Modified: ' . date('r', $stat['mtime']));
set_time_limit(0);
ignore_user_abort(!$mustExit);
header('Accept-Ranges: bytes');
header('Content-Transfer-Encoding: binary');
header('Content-Description: File Transfer');
if (ob_get_level()) {
while (@ob_end_clean()) {
}
}
$begin = 0;
$end = $stat['size'];
if (isset($_SERVER['HTTP_RANGE'])) {
if (preg_match('/bytes=\\h*(\\d+)-(\\d*)[\\D.*]?/i', $_SERVER['HTTP_RANGE'], $matches)) {
$begin = intval($matches[0]);
if (!empty($matches[1])) {
$end = intval($matches[1]);
}
}
}
$size = $end - $begin;
if (PHP_INT_SIZE <= 4 && $size >= 2147483647) {
passthru('cat ' . escapeshellarg($filename));
} else {
if (!ini_get("zlib.output_compression")) {
header('Content-Length:' . $size);
}
if ($size != $stat['size']) {
$f = @fopen($filename, 'rb');
if ($f === false) {
header("HTTP/1.0 505 Internal Server Error");
} else {
header('HTTP/1.0 206 Partial Content');
header("Content-Range: bytes " . $begin . "-" . $end . "/" . $stat['size']);
$cur = $begin;
fseek($f, $begin, 0);
while (!feof($f) && $cur < $end && !connection_aborted() && connection_status() == 0) {
print fread($f, min(1024 * 16, $end - $cur));
$cur += 1024 * 16;
}
fclose($f);
}
} else {
header('HTTP/1.0 200 OK');
readfile($filename);
}
}
}
}
if ($mustExit) {
exit(0);
} else {
return true;
}
}
return false;
}
示例13: error_reporting
* This information must remain intact.
*/
error_reporting(0);
require_once '../../common.php';
checkSession();
switch ($_GET['action']) {
case 'load':
if (file_exists(DATA . "/config/" . getFileName())) {
echo json_encode(getJSON(getFileName(), "config"));
} else {
echo json_encode(array());
}
break;
case 'save':
if (isset($_POST['data'])) {
saveJSON(getFileName(), json_decode($_POST['data']), "config");
echo '{"status":"success","message":"Data saved"}';
} else {
echo '{"status":"error","message":"Missing Parameter"}';
}
break;
case 'isDir':
if (isset($_GET['path'])) {
$result = array();
$result['status'] = "success";
$result['result'] = is_dir(getWorkspacePath($_GET['path']));
echo json_encode($result);
} else {
echo '{"status":"error","message":"Missing Parameter"}';
}
break;
示例14: addnew
public function addnew($data, $upload = true)
{
// dd($data);
extract($data);
$pathname = $upload == true ? getFileName('file') : 'default.txt';
$query = $this->db->prepare('INSERT INTO `surveys` (filename,pathname,sector_id) VALUES (:filename,:pathname,:sector)');
$query->bindParam(':filename', $filename, PDO::PARAM_STR);
$query->bindParam(':pathname', $pathname, PDO::PARAM_STR);
$query->bindParam(':sector', $sector, PDO::PARAM_STR);
$query->execute();
getError($query);
// dd(config('storage_path'));
if (hasFile('file')) {
move(config('storage_path_survey'), 'file');
}
}
示例15: getUpdate
<?php
include '_header.php';
$update = getUpdate($_GET['file']);
$teaserblocks = $update['page']->keyExists('teaserblocks') ? $update['page']->fetch('teaserblocks') : null;
if ($_POST) {
$file = buildFile();
$newFileName = getFileName($_POST['date'], $_POST['title']);
// delete current Markdown file
unlink($updates_dir . $_GET['file']);
// write new Markdown file
file_put_contents($updates_dir . $newFileName, $file);
chmod($updates_dir . $newFileName, 0777);
//echo "<textarea style='width: 100%; height: 500px;'>";
//echo $file;
//echo "</textarea>";
echo "<script>location.href = location.pathname + '?file=" . $newFileName . "';</script>";
}
?>
<form action="" method="post">
<fieldset>
<legend>Metadata</legend>
<div>
<label for="published">Published</label>
<div>
<input type="radio" name="published" value="true" <?php
if ($update['page']->fetch('published')) {
echo "checked";
}
?>