paulman888888 Posted May 19, 2008 Share Posted May 19, 2008 hi. I have a form that summits code useing the 'post' action and i would like a script that gets the post data and saves it as a new file in directory games. I would like the name to be anything.php i mean anything, number or what ever. thankyou Quote Link to comment https://forums.phpfreaks.com/topic/106317-solved-save-file/ Share on other sites More sharing options...
trq Posted May 19, 2008 Share Posted May 19, 2008 And you are stuck where? Were not here to write code for you. Quote Link to comment https://forums.phpfreaks.com/topic/106317-solved-save-file/#findComment-544848 Share on other sites More sharing options...
MadTechie Posted May 19, 2008 Share Posted May 19, 2008 whats the question ? what do you have so far EDIT: thorpe's post is more to the point Quote Link to comment https://forums.phpfreaks.com/topic/106317-solved-save-file/#findComment-544850 Share on other sites More sharing options...
paulman888888 Posted May 19, 2008 Author Share Posted May 19, 2008 And you are stuck where? Were not here to write code for you. am stuck trying to get post data to be saved as a random file with the extension .php I have tryed to make my own but they all fail. Thankyou for all the help Quote Link to comment https://forums.phpfreaks.com/topic/106317-solved-save-file/#findComment-544859 Share on other sites More sharing options...
MadTechie Posted May 19, 2008 Share Posted May 19, 2008 what do you have so far ? how did it fail ? Quote Link to comment https://forums.phpfreaks.com/topic/106317-solved-save-file/#findComment-544865 Share on other sites More sharing options...
paulman888888 Posted May 19, 2008 Author Share Posted May 19, 2008 As a noob i don't know how much there was left to do. I started with get post. And had loads of gos trying to get it to save the file. I got the random file name part done. As you can tell i am not very smart with PHP. Thankyou all ver much again. Quote Link to comment https://forums.phpfreaks.com/topic/106317-solved-save-file/#findComment-544870 Share on other sites More sharing options...
MadTechie Posted May 19, 2008 Share Posted May 19, 2008 can you post the code you have so far.. may i ask why you want it random! (just curious) Quote Link to comment https://forums.phpfreaks.com/topic/106317-solved-save-file/#findComment-544877 Share on other sites More sharing options...
paulman888888 Posted May 19, 2008 Author Share Posted May 19, 2008 can you post the code you have so far.. may i ask why you want it random! (just curious) I just don't want it to over right a file that is already there and i thought RANDOM would be a good way to prevent it. Am really sorry but when i couldn't do it I delete it of local on my server. Sorry Quote Link to comment https://forums.phpfreaks.com/topic/106317-solved-save-file/#findComment-544878 Share on other sites More sharing options...
corbin Posted May 19, 2008 Share Posted May 19, 2008 http://www.tizag.com/phpT/postget.php http://www.tizag.com/phpT/files.php (read the pages after this one too) http://php.net/fopen http://php.net/fwrite http://php.net/fclose Read those, and I bet you can come up with something. Quote Link to comment https://forums.phpfreaks.com/topic/106317-solved-save-file/#findComment-544893 Share on other sites More sharing options...
MadTechie Posted May 19, 2008 Share Posted May 19, 2008 I just don't want it to over right a file that is already there and i thought RANDOM would be a good way to prevent it. bad move, you can still over write files.. Am really sorry but when i couldn't do it I delete it of local on my server. well attempt to write one and post the code and where your stuck, if you really don't want to spend the time then try the freelance section Quote Link to comment https://forums.phpfreaks.com/topic/106317-solved-save-file/#findComment-544900 Share on other sites More sharing options...
paulman888888 Posted May 19, 2008 Author Share Posted May 19, 2008 I can't do this. It's too hard for me. I know this will sound abit weird but can someone make a template for me please. I've tryed and now its (a word that am not going to say because were not allowed to swear on these forums but i think you can guess it. But i will say it's a 7 letter word, begging with p has two s's init, and ends in 'ing' ) Please help! Quote Link to comment https://forums.phpfreaks.com/topic/106317-solved-save-file/#findComment-544939 Share on other sites More sharing options...
paulman888888 Posted May 19, 2008 Author Share Posted May 19, 2008 Below it my code. Please can you check it for errors as i am not very good. <?php $ourFileName = "games/$_POST[name].php"; $ourFileHandle = fopen($ourFileName, 'w') or die("Can't make file"); fclose($ourFileHandle); $myFile = "games/$_POST[name].php"; $fh = fopen($myFile, 'w') or die("There's an error!"); $stringData = "$_POST[main].php"; fwrite($fh, $stringData); fclose($fh); ?> This is what it's meant to do. Its meant to create a file in directory games. With the name from POST DATA NAME Then its meant to add the content from POST DATA MAIN Thank-you for all the help Quote Link to comment https://forums.phpfreaks.com/topic/106317-solved-save-file/#findComment-544954 Share on other sites More sharing options...
BlueSkyIS Posted May 19, 2008 Share Posted May 19, 2008 "games/$_POST[name].php"; should be "games/{$_POST['name']}.php"; Quote Link to comment https://forums.phpfreaks.com/topic/106317-solved-save-file/#findComment-544961 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.