need help with little script

Hello!!! Everbody

is there anyone out there who can help me?
I have this script which is programmed to receive data from an android app and save it as txt file.
txt files will automatically save in the same folder as the php file is located in.

but I want it to store files on an activ FTP server instead.

Someone who can change it for me?
There is the username and password to ftp server

[php]<?php
/*

  • Written By: René Ibsen
  • Date: 2012/03/21

*/

/CONFIG****/

//SETTINGS//
//This code is something you set in the APP so random people cant use it.
$ACCESSKEY=“serverPassword”;

/CONFIG****/

//these are just in case setting headers forcing it to always expire and the content type to CSV
header(‘Cache-Control: no-cache, must-revalidate’);
header(‘Content-type: text/csv’);

error_log(print_r($_POST,TRUE));

if( isset($_POST[‘export’]) && isset($_POST[‘key’]) ){ //checks ifthe tag post is there and if its been a proper form post
if($_POST[‘key’]==$ACCESSKEY){ ///validate the ACCESS key
$export=urldecode($_POST[‘export’]);
$outstream = fopen(’./export’.date(“YmdHis”).’.txt’, ‘w’);
fputs($outstream, $export);
fclose($outstream);
echo $export; //writes out csv data back to the client
} else {
header(“HTTP/1.0 400 Bad Request”);
echo “Bad Request”; //reports if the code is bad
}

} else {
header(“HTTP/1.0 400 Bad Request”);
echo “Bad Request”;
}
?>[/php]

if you don’t mind me asking, but what are you exporting from a phone?

Barcodes to a t&t system, We Will have Real time tracking

Just making sure, i get a little leary when i read things like this.

One thing i do see is your access checking. It need to go before you check the export post. otherwise, the script is still running even if i don’t have proper access. To store files on an ftp server, you need to first open the connection like you normally would if you were using a regular ftp program. Once its open, you can transfer the file to the remote server. You’ll have to store the file locally though, then transfer it.

Okay, but how do I do that? is noob to php

Sponsor our Newsletter | Privacy Policy | Terms of Service