Send Datas From Ipad and save over Apache+PHP on a Windows-Folder as INI-File: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
(Created page with "In this example I will show how I send my data from ipad on Windows-PC and later save it as INI-File to a windows-folder. ==save.php== This file gets the datas through POST, ...")
 
Line 2: Line 2:


==save.php==
==save.php==
save.php is saved into xampp-Ordner d:\xammp\htdocs\Kasse\save.php
This file gets the datas through POST, parses it, and then save the datas as ini-file under the directory "'''C:\Kasse10\Bestellungen\'''"
This file gets the datas through POST, parses it, and then save the datas as ini-file under the directory "'''C:\Kasse10\Bestellungen\'''"



Revision as of 19:54, 28 May 2013

In this example I will show how I send my data from ipad on Windows-PC and later save it as INI-File to a windows-folder.

save.php

save.php is saved into xampp-Ordner d:\xammp\htdocs\Kasse\save.php

This file gets the datas through POST, parses it, and then save the datas as ini-file under the directory "C:\Kasse10\Bestellungen\"

<?php
     
    header('Access-Control-Allow-Origin: *');
    //header("Access-Control-Allow-Credentials", "true");
           
    ini_set('display_errors','1');
    $backup_dir = "c:\\Kasse10\\Bestellungen\\";
         
    // Get the data from the client.  
    $myText = file_get_contents('php://input');
    /* buradan */
    $tmp = explode(",",$myText);
    $myFile = $tmp[0];
    $myText = str_replace(";","\r\n",$tmp[1]);
    /* buraya kadar */      
    $myFile= $backup_dir . $myFile;
     
    echo "Data received from Device:<br>" . $myText;  
    echo "<p>Writing data to " . $myFile;
    $f = fopen($myFile, 'w') or die("can't open file");
    fwrite($f, $myText);
    fclose($f);
     
?>