Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

How do I change where my php file saves a file?

$
0
0

Right now I have a PHP code which takes a template, changes some things on it, and saves it to the same folder the .php file is in. How do I make it so that I can change where that file is saved?

<?php

if($_POST['submit']) 
{ 
    $name = htmlspecialchars($_POST['sName']); 
    $ip = htmlspecialchars($_POST['sIp']); 
    $port = htmlspecialchars($_POST['sPort']); 
    $desc = htmlspecialchars($_POST['sDesc']); 
    $finalName = $ip."(".$port.").html";

$writestring = '                        <tr> 
                <td class="trank">*</td> 
                <td class="tname"><p class="wrap-tname"><a href="/server/5510">'.$name.'</a></p></td> 
                <td class="tserver"><a href="/server/5510"><img style="border:none;width:468px;height:60px;" src="/uniqueminecraftservers/slist/banners/1.jpg"></a><br>IP: '.$ip.'</td> 
                <td class="ttype"><p class="wrap-ttype">'.$port.'</p></td> 
                <td class="tplayers">2078/3000 

</td> 
                <td class="tstatus Online">Online 

</td> 
            </tr>';  

if (file_exists($ip."(".$port.").html")) {
  echo 'File already exists';
} else {

$finalName = $ip."(".$port.").html";

$file = fopen($finalName, "w"); 
    $size = filesize($finalName); 
     
     
    fwrite($file, $writestring); 
    fclose($file); 
    echo 'File Saved. Your server is now listed!';
}
}
 
$url = "http://www.maytagaclasvegas.com/uniqueminecraftservers/";
function redirect($url){
    if (headers_sent()){
      die('<script type="text/javascript">window.location.href="' . $url . '";</script>');
    }else{
      header('Location: ' . $url);
      die();
    }    
}

?>

Thanks!

-HeyAwesomePeople


Viewing all articles
Browse latest Browse all 13200

Trending Articles