本文整理汇总了PHP中renameFile函数的典型用法代码示例。如果您正苦于以下问题:PHP renameFile函数的具体用法?PHP renameFile怎么用?PHP renameFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了renameFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadFileForServer
function uploadFileForServer($name, $file)
{
$arr = array_keys($file);
$nameArr = implode($arr);
$types = array('image/gif', 'image/png', 'image/jpeg');
$size = 1024000;
$nameGen = substr(md5(rand()), 0, 7);
$typeFile = $_FILES[$nameArr]['type'];
$newName = renameFile($nameGen, $typeFile);
$upload = DIR . '/' . $newName;
$name = empty($name) ? 'no name' : $name;
$tupefile = $_FILES[$nameArr]['type'];
if (in_array($_FILES[$nameArr]['type'], $types) && $_FILES[$nameArr]['size'] < $size) {
if (is_uploaded_file($_FILES[$nameArr]['tmp_name'])) {
connectDB();
insertTable($newName, $name);
return move_uploaded_file($_FILES[$nameArr]['tmp_name'], $upload);
}
}
}
示例2: sanitizeString
$_POST['action'] = sanitizeString($_POST['action']);
switch ($_POST['action']) {
case "getFile":
getFile();
break;
case "saveFile":
saveFile();
break;
case "createNewFile":
createNewFile();
break;
case "createDir":
createDir();
break;
case "renameFile":
renameFile();
break;
case "removeFile":
removeFile();
break;
case "duplicateFile":
duplicateFile();
break;
case "moveFile":
moveFile();
break;
case 'uploadFile':
uploadFile();
break;
case 'checkForExistentFile':
checkForExistentFile();
示例3: writeOngoing
" />
<input type="submit" name="egal" value="<?php
echo $lang['cancel'];
?>
" />
<input type="hidden" name="name" value="<?php
echo $HTTP_POST_VARS['name'];
?>
" />
</form>
</div>
<?php
}
if ($HTTP_POST_VARS['rename'] != "") {
writeOngoing($lang['renamingFile']);
if (renameFile($HTTP_POST_VARS['name'], $HTTP_POST_VARS['newName'])) {
showNotification("File has been renamed", $config['appName'], $lang['renameDone'], $iconPath);
writeSuccess($lang['renameDone']);
} else {
showNotification("File rename error", $config['appName'], $lang['renameError'], $iconPath);
writeWarning($lang['renameError']);
}
}
if ($HTTP_POST_VARS['remail'] != "") {
sendMail($HTTP_POST_VARS['mailAdresses'], "/" . $config['fileDir'] . $HTTP_POST_VARS['name'], $config, $lang);
}
if ($HTTP_POST_VARS['delete'] == $lang['yes']) {
writeOngoing($lang['deleting']);
# first we have to be aware that some evil guy trys to delete files
# outside of our directory by deleting ".." and "/" in filename
$deleteFile = $HTTP_POST_VARS['name'];
示例4: createNewFolder
$currentDirectory = $baseDirectory;
if ($relativeDirectory != '') {
$currentDirectory .= "/" . $relativeDirectory . "/";
}
$column = $_POST['column'] ? $_POST['column'] : "name";
$order = $_POST['order'] ? $_POST['order'] : "ascending";
$message = "";
$errorMessage = "";
if ($task == "createFolder") {
$message .= createNewFolder($currentDirectory, $newFolder);
}
if (isset($_POST['submitUpload'])) {
$message .= uploadFile($_FILES["uploadFile"], $currentDirectory);
}
if ($task == "removeFile") {
$message .= removeFile($currentDirectory, $deleteFile);
}
if ($task == "renameFile") {
$message .= renameFile($currentDirectory, $renameFrom, $renameTo);
}
$directoryList = getDirectoryList($currentDirectory);
$fileList = getFileList($currentDirectory);
$navigationList["Fnow"] = str_replace('\\', '/', pFNOW);
$navigationList["base"] = $cfg['base_directory'];
$navigationList["relative"] = $relativeDirectory;
$navigationList["column"] = $column;
$navigationList["order"] = $order;
$navigationList["pathData"] = $def['DIRECTORY'];
$directoryListXML = setDirectoryListXML($currentDirectory, $navigationList, $directoryList, $fileList, $message);
$result = processTransformation($directoryListXML, pFNOW . "/xsl/directoryList.xsl");
print $result;
示例5: renameFile
$name = "{$dir}/{$_POST["newfile"]}";
renameFile($name, $phpendings, $editphp, $showphp, $allowedfile, $dir);
} else {
echo "<p class=\"error\">" . printMsg("err") . printMsg("errNoMove") . "</p>";
}
} else {
echo "<p class=\"error\">" . printMsg("err") . printMsg("errNoMove") . "</p>";
}
} else {
$name = "{$dir}/{$_POST["newfile"]}";
renameFile($name, $phpendings, $editphp, $showphp, $allowedfile, $dir);
}
} else {
// Else we rename the file in question.
$name = "{$dir}/{$_POST["newfile"]}";
renameFile($name, $phpendings, $editphp, $showphp, $allowedfile, $dir);
}
} elseif ($action == "savefile") {
// Save a file that has been edited.
$editfile = stripslashes($_POST["editfile"]);
if ($_POST["submittype"] != "") {
if (checkForEdit(getExt($editfile)) == 1) {
$filecontent = stripslashes($_POST["filecontent"]);
if ($_POST["convertspaces"] != "") {
$filecontent = str_replace(" ", "\t", $filecontent);
}
if (is_writeable("{$editfile}")) {
$fp = fopen("{$editfile}", "wb");
fputs($fp, $filecontent);
fclose($fp);
echo "<p class=\"okay\">" . printMsg("textEdit", $editfile) . "</p>";
示例6: renameFile
if (strpos($fieldID, 'DS') !== false) {
$cat = "Dissolution";
}
if (strpos($fieldID, 'RS') !== false) {
$cat = "RelatedSubstance";
}
if (strpos($fieldID, 'MCT') !== false) {
$cat = "MCT";
}
if (strpos($fieldID, 'STE') !== false) {
$cat = "Sterility";
}
if (strpos($fieldID, 'BET') !== false) {
$cat = "BET";
}
$file_name = renameFile($product, basename($_FILES[$fieldID]["name"]));
$target_file = $target_dir . $file_name;
move_uploaded_file($_FILES[$fieldID]["tmp_name"], $target_file);
saveToDB2($kp_id, $fieldID, $file_name, $attach_loc, $target_dir, $method, $cat, basename($_FILES[$fieldID]["name"]));
}
}
}
function renameFile($v, $files)
{
$ext = pathinfo($files, PATHINFO_EXTENSION);
return $v . "_" . getCurrentDT() . "." . $ext;
}
function getCurrentDT()
{
return date("Ymdhis");
}
示例7: cgiResponse
cgiResponse($status, "Not Found", null);
}
break;
case "GET":
$files = getFile($fullPath, $rootDir, $args, $status);
$total = count($files);
// Compile the final result
$result = new stdClass();
$result->total = $total;
$result->status = $total ? HTTP_V_OK : HTTP_V_NO_CONTENT;
$result->items = $files;
header("Content-Type: text/json");
print json_encode($result);
break;
case "POST":
$files = renameFile($fullPath, $rootDir, $args, $status);
// Compile the final result
if ($status == HTTP_V_OK) {
$result = new stdClass();
$result->total = count($files);
$result->status = $status;
$result->items = $files;
header("Content-Type: text/json");
print json_encode($result);
} else {
cgiResponse($status, "system error.", "Failed to rename file.");
}
break;
}
} else {
cgiResponse(HTTP_V_NOT_FOUND, "Not Found", "Invalid path and/or basePath.");
示例8: alertMes
}
alertMes($mes, $redirect);
} elseif ($act == "renameFile") {
//完成重命名
$str = <<<EOF
\t<form action="index.php?act=doRename" method="post">
\t请填写新文件名:<input type="text" name="newname" placeholder="重命名"/>
\t<input type='hidden' name='filename' value='{$filename}' />
\t<input type="submit" value="重命名"/>
\t</form>
EOF;
echo $str;
} elseif ($act == "doRename") {
//实现重命名的操做
$newname = $_REQUEST['newname'];
$mes = renameFile($filename, $newname);
alertMes($mes, $redirect);
} elseif ($act == "delFile") {
$mes = delFile($filename);
alertMes($mes, $redirect);
} elseif ($act == "downFile") {
//完成下载的操作
$mes = downFile($filename);
} elseif ($act == "创建文件夹") {
$mes = createFolder($path . "/" . $dirname);
alertMes($mes, $redirect);
} elseif ($act == "renameFolder") {
$str = <<<EOF
\t\t\t<form action="index.php?act=doRenameFolder" method="post">
\t请填写新文件夹名称:<input type="text" name="newname" placeholder="重命名"/>
\t<input type="hidden" name="path" value="{$path}" />
示例9: renameFile
#!/usr/bin/env php
<?php
function renameFile($filename)
{
$text = file_get_contents($filename);
$slug = getSlug($text);
if ($slug) {
var_dump($slug);
rename($filename, $slug . '.md');
}
}
function getSlug($text)
{
$pattern = '/slug:\\s+(.*)/';
preg_match($pattern, $text, $matches, PREG_OFFSET_CAPTURE);
if (!$matches) {
return null;
}
return $matches[1][0];
}
$dir = new DirectoryIterator(dirname(__FILE__));
foreach ($dir as $fileinfo) {
if ($fileinfo->isDot()) {
continue;
}
if (strpos($fileinfo->getFilename(), 'xx') !== false) {
renameFile($fileinfo->getFilename());
}
}
示例10: move_uploaded_file
}
}
if (!is_file($_FILES['uploadFile']['tmp_name'])) {
return _filemanager_filenotuploaded;
}
move_uploaded_file($_FILES['uploadFile']['tmp_name'], $newFile);
chmod($newFile, 0666);
$clear_upload = true;
return false;
}
if (isset($_REQUEST['action'])) {
if ('delete' == $_REQUEST['action']) {
$err = deleteFile();
}
if ('rename' == $_REQUEST['action']) {
$err = renameFile();
}
if ('move' == $_REQUEST['action']) {
$err = moveFile();
}
if ('createFolder' == $_REQUEST['action']) {
$err = createFolder();
}
}
if (isset($_FILES['uploadFile']) && is_array($_FILES['uploadFile'])) {
$err = uploadFile();
}
function parse_size($size)
{
if ($size < 1024) {
return $size . ' bytes';
示例11: moveFileDir
function moveFileDir()
{
if ($_SESSION['adminType'] == 'sadmin') {
$fileManPath = RAZOR_SADMIN_PATH;
} else {
$fileManPath = RAZOR_FILEMAN_PATH;
}
$oldName = '';
$newName = '';
if (isset($_POST['oldfilename']) && $_POST['oldfilename']) {
$oldName = $_POST['oldfilename'];
}
if (isset($_POST['olddirname']) && $_POST['olddirname']) {
$oldName = $_POST['olddirname'];
}
if (isset($_POST['newdirname']) && $_POST['newdirname']) {
$newName = $_POST['newdirname'];
}
$oldPath = $fileManPath . $oldName;
$newPath = $fileManPath . $newName . '/' . basename($oldName);
if (!file_exists(getSystemRoot(RAZOR_ADMIN_FILENAME) . $newPath)) {
if (renameFile($oldPath, $newPath, false)) {
MsgBox(lt('Move complete'), 'greenbox');
} else {
MsgBox(lt('Error when moving'), 'redbox');
}
} else {
MsgBox(lt('Name already exists, error when moving'), 'redbox');
}
}
示例12: saveImage
/**
* Save image in various formats
*
* @param
* @return
*/
function saveImage($image)
{
//1.Original Image
// Separate the uploaded file array
list($name, $type, $tmp, $err, $size) = array_values($image);
//get extension
$ext = getImageExtensions($type);
//rename
$filename = renameFile($ext);
$coverimagePath = $_SERVER['DOCUMENT_ROOT'] . APP_FOLDER . "/img/original/" . $filename;
//save original
if (!move_uploaded_file($tmp, $coverimagePath)) {
throw new Exception("Couldn't save the uploaded image!");
}
//2.save small, medium and large image
$destination = '../img/small/' . $filename;
resizeAndSaveImage($coverimagePath, $destination, 143, 143);
$destination = '../img/medium/' . $filename;
resizeAndSaveImage($coverimagePath, $destination, 750, 450);
$destination = '../img/large/' . $filename;
$img = new abeautifulsite\SimpleImage($coverimagePath);
$img->best_fit(2000, 2000)->save($destination);
//3.remove original
unlink($coverimagePath);
//4.return filename
return $filename;
}
示例13: returnErrorCode
echo returnErrorCode(3);
}
} else {
echo returnErrorCode(2);
}
} else {
echo returnErrorCode(1);
}
} else {
if (isset($_GET['type']) && $_GET['type'] == "file" && isset($_GET['action']) && $_GET['action'] == "update" && isset($_GET['project']) && isset($_GET['file']) && isset($_GET['newname'])) {
$project = htmlentities(mysql_real_escape_string($_GET['project']));
$file = htmlentities(mysql_real_escape_string($_GET['file']));
$new_file = htmlentities(mysql_real_escape_string($_GET['newname']));
if (check($login) == 1) {
if (authenticate($login, $password)) {
if (renameFile($login, $project, $file, $new_file)) {
echo buildJSONResponse(array("create" => "ok", "updated" => "ok", "files" => listFiles($login, $project)));
} else {
echo returnErrorCode(3);
}
} else {
echo returnErrorCode(2);
}
} else {
echo returnErrorCode(1);
}
} else {
if (isset($_GET['type']) && $_GET['type'] == "file" && isset($_GET['action']) && $_GET['action'] == "update" && isset($_GET['project']) && isset($_GET['file']) && isset($_POST['data'])) {
$project = htmlentities(mysql_real_escape_string($_GET['project']));
$file = htmlentities(mysql_real_escape_string($_GET['file']));
if (check($login) == 1) {
示例14: parseXml
$sContents = parseXml($aXmlTemplates['result'], "msgErrorUpload", FAILED_VAL);
$sTempFileName = $sFilesPath . $sId . TEMP_FILE_NAME;
if (!file_exists($sTempFileName)) {
break;
}
$sConvert = isset($_REQUEST['convert']) ? $_REQUEST['convert'] : TRUE_VAL;
$bJustRename = $sConvert != TRUE_VAL;
if (!convert($sId, $bJustRename)) {
deleteTempFiles($sId);
break;
}
$sAutoApprove = $bAdmin ? TRUE_VAL : getSettingValue($sModule, "autoApprove");
$sUri = genUri($sTitle);
getResult("INSERT INTO `" . MODULE_DB_PREFIX . "Files`(`CategoryId`, `Title`, `Uri`, `Tags`, `Description`, `Date`, `Owner`, `Approved`) VALUES ('" . $sCategory . "', '" . $sTitle . "', '" . $sUri . "', '" . $sTags . "', '" . $sDesc . "', '" . time() . "', '" . $sId . "', '" . $sAutoApprove . "')");
$sFileId = getLastInsertId();
if (!renameFile($sId, $sFileId)) {
deleteTempFiles($sId);
getResult("DELETE FROM `" . MODULE_DB_PREFIX . "Files` WHERE `ID`='" . $sFileId . "' LIMIT 1");
break;
}
$sNewFileName = $sFileId . MP3_EXTENSION;
deleteTempFiles($sId, true);
parseTags($sFileId);
if ($sId != "0") {
getResult("UPDATE `" . MODULE_DB_PREFIX . "PlayLists` SET `Order`=`Order`+1 WHERE `Owner` = '" . $sId . "'");
getResult("INSERT INTO `" . MODULE_DB_PREFIX . "PlayLists` VALUES('" . $sFileId . "', '" . $sId . "', '1')");
}
$sContents = parseXml($aXmlTemplates['result'], "", SUCCESS_VAL);
$sContents .= parseXml($aXmlTemplates['file'], $sFileId, $sNewFileName);
break;
case 'updateFile':
示例15: foreach
<?php
foreach ($files as $fl) {
$fl_nm = explode("_", $fl);
$fl_timest = explode(".", $fl_nm[2]);
if (count($fl_timest[0]) != 12) {
if (substr($fl_timest[0], 2) != 10) {
$new_fl_nm = substr_replace($fl_nm[2], "0" . substr($fl_timest[0], 2, 2), 2, count($fl_nm));
$new_fl_nm = $fl_nm[0] . "_" . $fl_nm[1] . "_" . $new_fl_nm;
//echo $new_fl_nm;die;
if (copy_file($fl, $dir, $files_to_rename)) {
// copy file to be rename
if (renameFile($fl, $new_fl_nm, $dir, $dir)) {
// rename file
echo "file '{$fl}' renamed to '{$new_fl_nm}'.";
} else {
echo "file '{$fl}' not renamed.";
}
}
}
}
}