Drags111 Posted November 11, 2007 Share Posted November 11, 2007 Ok, I have a script thats writes 2 files to 2 different folders in my server. I know that usualy, I can just type the location as folder1/file.txt and it would write to folder1. But heres the layout: I want that php file to write to the folders (Folder1 and Folder2). How would I go about doing this? Heres is the script I use and it doesnt work. <?php $contents = "http://www.gma.asssoft.org/Ids/".$_POST['usr'].".txt"; $contents2 = "http://www.gma.asssoft.org/IdPass/".$_POST['pass'].".txt"; $headers = "From: [email protected]"; file_put_contents($contents, $_POST['ipa']); echo "Successfuly wrote the file: $contents with the ip of: $_POST[ipa] to the system."; file_put_contents($contents2, $_POST['pass']); echo "\nDone.\nSuccessfuly wrote the file: $contents2 with the password of: $_POST[pass] to the system."; $body = "UserID: $usr\nPass: $_POST[pass]\nIP Address Registered: $_POST[ipa]\nThank you for registering to Graph Master! Please email problems to [email protected]."; mail($_POST['email'], "Account Created!", $body, $headers); ?> Link to comment https://forums.phpfreaks.com/topic/76883-problem-writing-to-a-folder-in-my-server/ Share on other sites More sharing options...
BlueSkyIS Posted November 11, 2007 Share Posted November 11, 2007 int file_put_contents ( string filename, mixed data [, int flags [, resource context]] ) you must use filename, not URL. Link to comment https://forums.phpfreaks.com/topic/76883-problem-writing-to-a-folder-in-my-server/#findComment-389259 Share on other sites More sharing options...
Daukan Posted November 11, 2007 Share Posted November 11, 2007 You should do some validation and sanitation on the post data if you are going to use it in a file path. Link to comment https://forums.phpfreaks.com/topic/76883-problem-writing-to-a-folder-in-my-server/#findComment-389264 Share on other sites More sharing options...
Drags111 Posted November 11, 2007 Author Share Posted November 11, 2007 i know but usualy i can do this: folder2/file.txt and it works. I know for a fact it does cuz i use it on my other scripts that are in the main top-most folder. Link to comment https://forums.phpfreaks.com/topic/76883-problem-writing-to-a-folder-in-my-server/#findComment-389266 Share on other sites More sharing options...
Drags111 Posted November 11, 2007 Author Share Posted November 11, 2007 You should do some validation and sanitation on the data if you are going to use it in a file path. what do you mean? Link to comment https://forums.phpfreaks.com/topic/76883-problem-writing-to-a-folder-in-my-server/#findComment-389267 Share on other sites More sharing options...
Daukan Posted November 11, 2007 Share Posted November 11, 2007 You have post data in the url. Its possible they could run arbitrary code or at the very least enter characters that could cause internal server errors $contents = "http://www.gma.asssoft.org/Ids/".$_POST['usr'].".txt"; $contents2 = "http://www.gma.asssoft.org/IdPass/".$_POST['pass'].".txt"; Link to comment https://forums.phpfreaks.com/topic/76883-problem-writing-to-a-folder-in-my-server/#findComment-389270 Share on other sites More sharing options...
Drags111 Posted November 11, 2007 Author Share Posted November 11, 2007 no i dont think thats the case. I have an idea so I'm going to try this one more thing. EDIT: also it would work if i could do something like "go up one level" then it would be in the websitefolder and can navigate down. But i dont think thats possible. EDIT 2: I tried something and got this error: Warning: file_put_contents(gma.asssoft.org/Ids/Test.txt) [function.file-put-contents]: failed to open stream: No such file or directory in /home/.monochrome/drags111/gma.asssoft.org/adminonly/reg235246.php on line 6 So basicly, I do need to go up-one-level in the folders so i could be in the main folder and navigate down. Possible? Link to comment https://forums.phpfreaks.com/topic/76883-problem-writing-to-a-folder-in-my-server/#findComment-389272 Share on other sites More sharing options...
Drags111 Posted November 11, 2007 Author Share Posted November 11, 2007 yah ive been trying tons of things but i cant get it to work. Link to comment https://forums.phpfreaks.com/topic/76883-problem-writing-to-a-folder-in-my-server/#findComment-389293 Share on other sites More sharing options...
Drags111 Posted November 11, 2007 Author Share Posted November 11, 2007 so, what? is there nothing i can do? Link to comment https://forums.phpfreaks.com/topic/76883-problem-writing-to-a-folder-in-my-server/#findComment-389425 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.