Jump to content

[SOLVED] New Page


s1yman

Recommended Posts

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

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

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.