Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if( $_SESSION["username"]==""){
- header("Location: http://filewallet.site88.net/");
- }
- else{
- $servername = "mysql1.000webhost.com";
- $username = "a9691255_naveed";
- $password = "abmirzass123";
- $dbname = "a9691255_webiste";
- $userid=$_SESSION["username"];
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- if(isset($_GET["choice"])){
- $choice=$_GET["choice"];
- if($choice==1)
- {
- $path=$_GET["path"];
- $filename=$_GET["filename"];
- }
- if($choice==2)
- {
- $filename=$_GET["filename"];
- echo $filename;
- }
- }
- }
- ?>
- <html>
- <body>
- <?php
- if(isset($_POST["submit"])){
- $oldname=$_POST["oldname"];
- $newname=$_POST["newname"];
- $filepath="upload/".$userid;
- if (strpos($oldname, '.') !== false) {
- $filecheck=1;
- }
- else{$filecheck=2;}
- if($filecheck==1){
- $query="update fileuploads set filename='".$newname."' ,filepath='".$filepath."/".$newname."' where filename='".$oldname."' and userid='".$userid."'";
- if($conn->query($query))
- {
- if(rename($filepath."/".$oldname,$filepath."/".$newname))
- header("Location: main.php?renamecheck=1");
- else
- header("Location: main.php?renamecheck=2");
- }
- }
- if($filecheck==2){
- if(rename($filepath."/".$oldname,$filepath."/".$newname))
- header("Location: main.php?renamecheck=1");
- }
- }
- ?>
- <form method="post" action="rename.php">
- Old File Name : <input type="text" name="oldname" width="100px" value="<?php echo $filename; ?>" readonly><br>
- New File name : <input type="text" name="newname" width="100px"><br>
- <input type="submit" name="submit">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement