s1yman Posted August 9, 2008 Share Posted August 9, 2008 Is PHP able to create a new page on an ftp server, for example using data from a form? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/118916-solved-new-page/ Share on other sites More sharing options...
BioBob Posted August 9, 2008 Share Posted August 9, 2008 Not directly. Thats a limitation of FTP not php. A not so easy workaround would be to have php generate the file locally, then ftp it up. Link to comment https://forums.phpfreaks.com/topic/118916-solved-new-page/#findComment-612322 Share on other sites More sharing options...
s1yman Posted August 9, 2008 Author Share Posted August 9, 2008 I see, not going to be the easiest of scripts though is it? Link to comment https://forums.phpfreaks.com/topic/118916-solved-new-page/#findComment-612374 Share on other sites More sharing options...
s1yman Posted August 11, 2008 Author Share Posted August 11, 2008 Does anyone else have any ideas, or care to help me with a script? Please! Link to comment https://forums.phpfreaks.com/topic/118916-solved-new-page/#findComment-613476 Share on other sites More sharing options...
DarkWater Posted August 11, 2008 Share Posted August 11, 2008 Well, PHP definitely can. You'd probably do something like: //here's where you put together the file stuff $file = 'something' . 'something' . 2 * 2; //etc $fname = str_replace('.', '_', (string) (microtime(true) . '_' . rand())); //really unique filename, lol. so there's no overwriting incase the script is ran twice in a row or something file_put_contents($fname, $file); //connect to ftp and transfer $fname over, at which point you can rename it and stuff to something usable Link to comment https://forums.phpfreaks.com/topic/118916-solved-new-page/#findComment-613578 Share on other sites More sharing options...
s1yman Posted August 11, 2008 Author Share Posted August 11, 2008 Thanks for the help mate .. but I'm complete w*nk at this, so any chance you could break that down for me a bit more please? Thanks Link to comment https://forums.phpfreaks.com/topic/118916-solved-new-page/#findComment-613607 Share on other sites More sharing options...
DarkWater Posted August 11, 2008 Share Posted August 11, 2008 Well, firstly, you'd want to assemble your file data. Like, what you want in the file. $file="Name: {$_POST['name']} Email: {$_POST['email']}"; Or whatever you want the file to be. Then, you create a unique filename for it so it's not overwritten by accident. $fname = str_replace('.', '_', (string) (microtime(true) . '_' . rand())); That's more unique than you'll ever need. Then, you save that file data to a LOCAL file for uploading: file_put_contents($fname, $file); Then, you upload to the FTP server with PHP's FTP functions. Read up on the manual for how to use them (I'm not sure which ones you're going to need because I'm not sure what you're actually doing). It's a relatively straightforward process. Then, if you want, you can delete the local file: unlink($fname); Link to comment https://forums.phpfreaks.com/topic/118916-solved-new-page/#findComment-613609 Share on other sites More sharing options...
Jabop Posted August 11, 2008 Share Posted August 11, 2008 $filename=strtotime(NOW); how's that for unique? Link to comment https://forums.phpfreaks.com/topic/118916-solved-new-page/#findComment-613639 Share on other sites More sharing options...
DarkWater Posted August 11, 2008 Share Posted August 11, 2008 $filename=strtotime(NOW); how's that for unique? Mines uniquer-er. Especially if the script is accessed at the same time or something. xD Link to comment https://forums.phpfreaks.com/topic/118916-solved-new-page/#findComment-613641 Share on other sites More sharing options...
s1yman Posted August 11, 2008 Author Share Posted August 11, 2008 thanks mate, I'll give that a go Link to comment https://forums.phpfreaks.com/topic/118916-solved-new-page/#findComment-613655 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.