dc_jt Posted August 27, 2009 Share Posted August 27, 2009 Hi I am looking to create a csv file based on the data entered in a contact form and then upload this csv file to an FTP server. I have created the CSV using the following code but unsure how to upload this to the FTP site (which is on another server) rather than my own site. Any idea? $sDate=date('Y')."-".date('m')."-".date('d')."-".time(); $filename = $sDate."_contact.csv"; //path to uploads folder on my site $filename_path = UPLOADS_PATH.'/csv_files/'.$filename; //open the file for APPENDING //add the "t" terminator for windows //if using a mac then set the ini directive $fh = fopen($filename_path, "at"); //Lock the file for the write operation flock($fh, LOCK_EX); $sType = "Contact Form Enquiry"; $sName = explode(" ", $_POST[name]); $sForename = $sName[0]; $sSurname = $sName[1]; $top = 'Type,Forename,Surname,Company,Telephone,Email,Comment,Date Added,Notes'; $top .="\n"; $top .='"'.$sType.'",'; $top .='"'.$sForename.'",'; $top .='"'.$sSurname.'",'; $top .='"'.$_POST[company].'",'; $top .='"'.$_POST[telephone].'",'; $top .='"'.$_POST[email].'",'; $top .='"'.$_POST[comment].'",'; $top .='"'.date('d')."/".date('m')."/".date('Y').'",'; $top .='" ",'; $top .="\n"; fwrite($fh, $top ."\n",strlen($top)); fclose($fh); Quote Link to comment https://forums.phpfreaks.com/topic/172103-creating-csv-and-uploading-to-ftp-site/ Share on other sites More sharing options...
ignace Posted August 27, 2009 Share Posted August 27, 2009 http://us3.php.net/manual/en/book.ftp.php Quote Link to comment https://forums.phpfreaks.com/topic/172103-creating-csv-and-uploading-to-ftp-site/#findComment-907417 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.