本文整理汇总了PHP中Files::renameFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::renameFile方法的具体用法?PHP Files::renameFile怎么用?PHP Files::renameFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Files
的用法示例。
在下文中一共展示了Files::renameFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Session
<?php
require_once '../classes/Autoload.php';
$session = new Session();
if ($session->isLoggeg()) {
$cancion = new Cancion(Request::get('c'));
if ($cancion != null) {
if ($cancion->getPrivada()) {
$p = "A";
} else {
$p = "P";
}
$cancion->setPrivada();
$old = "../canciones/" . $cancion->getNombre();
$new = "../canciones/" . $p . substr($cancion->getNombre(), 1);
if (Files::renameFile($old, $new)) {
echo 'ok1';
}
if ($cancion->getImagen() !== 'default.jpg') {
$old = "../caratulas/" . $cancion->getImagen();
$new = "../caratulas/" . $p . substr($cancion->getImagen(), 1);
if (Files::renameFile($old, $new)) {
echo 'ok2';
}
}
}
}
Utils::redirect();
示例2: processRenames
/**
* Renames files if certain GET variables are set
* @return bool
*/
function processRenames()
{
if (!empty($_GET['rename']) && !empty($_GET['renameTo'])) {
// new file name (without path and extension)
$newName = Files::escape(rawurldecode($_GET['renameTo']));
$newName = str_replace('.', '', $newName);
// path to file (from base images directory)
$oldName = rawurldecode($_GET['rename']);
// strip parent dir ("..") to avoid escaping from base directiory
$oldName = preg_replace('#\\.\\.#', '', $oldName);
if (is_dir($oldPath = Files::makeFile($this->getImagesDir(), $_GET['dir'] . $oldName))) {
$newPath = Files::makeFile($this->getImagesDir(), $_GET['dir'] . $newName);
return Files::rename($oldPath, $newPath);
} else {
// path to old file
$oldPath = Files::makeFile($this->getImagesDir(), $oldName);
$ret = Files::renameFile($oldPath, $newName);
if ($ret === true) {
// delete old thumbnail
Files::delFile($this->getThumbname($oldPath));
}
}
return $ret;
}
return null;
}
示例3: date
// here call function to insert new data
if (isset($_GET['upload'])) {
$filename = $_FILES['upload']['name'];
$type = $_FILES['upload']['type'];
$size = $_FILES['upload']['size'];
$created = date('Y-m-d H:i:s');
$oFiles->newFile($filename, $type, $size, $created);
header('Location: user_area.php');
}
// actions von GET abfragen
if (isset($_GET['action']) && $_GET['action'] == "delete") {
$oFiles->deleteFile($_GET['id']);
header('Location: user_area.php');
}
if (isset($_GET['renamed']) && isset($_POST['rename_frm_submit'])) {
$oFiles->renameFile($_POST['fileid'], $_POST['oldfile'], $_POST['newname']);
header('Location: user_area.php');
}
//show this only when file should be renamed
if (isset($_GET['action']) && $_GET['action'] == "rename") {
$output .= "<div style='margin: 10px 10px; padding: 10px 10px; background-color: #CCC;' id='file_rename'>\n\t <span id='close_div'><img src='icons/close.png' style='float:right;' title='close'></span>\n <form method='post' action='user_area.php?renamed=1' name='filerename'>\n <input type='hidden' name='fileid' value='" . $_GET['id'] . "'>\n <input type='hidden' name='oldfile' value='" . $oFiles->getFileNameById($_GET['id']) . "'>\n new filename: <input type='text' name='newname' maxlength='100' size='100' value='" . $oFiles->getFileNameById($_GET['id']) . "'><br>\n <input type='submit' value='rename' name='rename_frm_submit'>\n </form>\n </div>";
}
//print_r($aUserFiles);
// show this, if user has files uploaded
if ($aUserFiles) {
$output .= "<div class='filelist'>";
$output .= "Hier sehen Sie alle Dateien, die Sie hochgeladen haben. <br>\n\t Wenn Sie in die rechte Spalte auf das Icon klicken, können Sie die Datei löschen, mit dem Icon auf der mittleren Spalte <br>\n\t\t können Sie es umbenennen. <br><br>";
$output .= "<table>";
$output .= "<tr>\n </tr><th>Filename</th><th>Filetype</th><th>Size</th><th>erstellt am</th><th>Download</th><th>Umbenennen</th><th>Löschen</th>\n </tr>";
for ($i = 0; $i < count($aUserFiles); $i++) {
$filetypeIcon = str_replace("/", "_", $aUserFiles[$i]['ftype']);