Jump to content

need help with auto save on ftp server


jojossdk

Recommended Posts

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
/*
* 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="password";

/************************************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";
}
?>

17857_.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.