kpetsche20 Posted February 25, 2009 Share Posted February 25, 2009 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> Link to comment https://forums.phpfreaks.com/topic/146950-how-do-i-move-a-file-to-another-directory/ Share on other sites More sharing options...
trq Posted February 26, 2009 Share Posted February 26, 2009 Can I ask why your attermpting to make php files dynamically in the first place? Link to comment https://forums.phpfreaks.com/topic/146950-how-do-i-move-a-file-to-another-directory/#findComment-771499 Share on other sites More sharing options...
kpetsche20 Posted February 26, 2009 Author Share Posted February 26, 2009 I find it somewhat pointless too but that is what my friend said he wants. Link to comment https://forums.phpfreaks.com/topic/146950-how-do-i-move-a-file-to-another-directory/#findComment-771506 Share on other sites More sharing options...
trq Posted February 26, 2009 Share Posted February 26, 2009 move_uploaded_file("/home/zionist/public_html/admin/$file", "/home/zionist/public_html/$file"); Link to comment https://forums.phpfreaks.com/topic/146950-how-do-i-move-a-file-to-another-directory/#findComment-771556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.