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
No edit summary
Line 4: Line 4:
save.php is saved into xampp-Ordner d:\xammp\htdocs\Kasse\save.php
save.php is saved into xampp-Ordner d:\xammp\htdocs\Kasse\save.php


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


From Ipad ist send via POST  
From Ipad ist send via POST  

Revision as of 20:12, 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 after each semicolon, and then save the datas as ini-file under the directory "C:\Kasse10\Bestellungen\"

From Ipad ist send via POST

  => FILE_NAME_TO_SAVED_Ini-File;Lines1_forIni;Line2_for_Ini;Line3_for_Ini;Line3_for_Ini


<?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);
     
?>

Ini-Files(Ordering Files)

This files contains information for order and later by a module on Windows-PC that I have written with Visual Studio 2008, edited and printed.

My ini-files looks like this:

[BON]
Kellner=5
Cheff=1
Tisch=17
Anzahl=4
Bestell_0=1*301<mit Eis, Ohne Zitrone>0
Bestell_1=1*302<mit Zitrone>0
Bestell_2=1*404<Ohne Eis>0
Bestell_3=1*503<Ohne Tomaten>0
Bestell_4=1*607<>0