Jump to content

How do I move a file to another directory


kpetsche20

Recommended Posts

Hey, I am having trouble moving a file to a different directory.

 

The script below creates a new file but it uploads to the /admin directory and it needs to upload to the directory before that.

 

<?php
if($_POST['submit'])
{
//mysql_query("INSERT INTO tblname (pagename, content) VALUES('".."', '".."')") or die(mysql_error());
$new_contents = 
"
<?php require \"includes/php/front/code/includes.php\" ?>
<?php require \"includes/php/front/pages/overall_header.php\" ?>

<?php
\$sql = mysql_query(\"SELECT * FROM cart WHERE id=id\") or die(mysql_error());
?>
<?php require \"includes/php/front/pages/overall_footer.php\" ?>
".$_POST['content']."
";
$file = $_POST['pagename'].".php";
$fh = fopen($file, 'x');
fwrite($fh, $new_contents);
fclose($fh);

move_uploaded_file('/home/zionist/public_html/admin/$file', '/home/zionist/public_html/$file');

}
echo getcwd();
?>
<form name="form" method="POST" action="">
Page Name: <input type="text" name="pagename" />
<br />
Content<br />
<textarea name="content" cols="40" rows="10"></textarea>
<input type="submit" name="submit" value="submit" />
</form>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.