ARDUINO and VB.NET - Read TEXT File from WEB SERVER

Contributor
Submitted by CAAadmin on Sun, 07/16/2017 - 15:48
arduino read data from server

This project details and full source codes are available at www.arduinovb.net  (maintained at separate server for php trial and error purpose)

arduino vb.net read data from server

we can read the data file stored in Server (with public access permission) and display in the RichTextBox

The Updated Items in code

Usual import libraries

Imports System.IO

Imports System.Text

Imports System.Net

 

I have added a textbox (TextBox1) to read the web address and a Command Button (CommandButton1) and Richtext box (RichTextBox2) to display the data

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim address As String

        'address = "http://www.arduinovb.net/temp1/txtfiles/trial-1.txt"

        address = TextBox1.Text

        If (address = "") Then

        Else

            Dim client As WebClient = New WebClient()

            Dim reply As String = client.DownloadString(address)

            RichTextBox2.Text = reply

        End If

    End Sub

The data written in the text file (server)

arduino vb read data

Our OUTPUT (from the Version2.0)

arduino

ARDUINOVB.NET V2.0 PHP FUNCTIONS

PHP function used to write in to the text file from a web form is as shown below

 

<?php

function functiontrial1(){

?>

<form id="form1" method="post" action="">

<input name="search1" type="search" autofocus>

<input type="submit" formaction="" name="button1">

</form>

<?php

if(isset($_POST['button1']))

{    //trigger button click

$search=$_POST['search1'];

echo $search;

$myfile = fopen("txtfiles/trial-1.txt", "w") or die("Unable to open file!");

fwrite($myfile, $search);

fclose($myfile);

}}

?>

 

Save this file as

trial-1.inc.php

and include in any php file where you need form like

include 'trial-1.inc.php';

in my case, it is the index.php file with login functionalities for trial purposes

 

<?php

require 'core.inc.php';

require 'connect.inc.php';

include 'trial-1.inc.php';

if(loggedin())

{

$name = getuserfield('name');

echo 'You are logged in '.$name.' ,  <a href="logout.php">Log Out</a><br>';

functiontrial1(); // write to text file form is available in this function

}

else

{

include 'loginform.inc.php';

}

?>

Tags