2

ok so im working on uploading files to a database, i wrote the upload part in php. but i want vb to execute it. i would write it over in vb but im not the best vb programmer cause i just started using it. so what i want is when the user clicks the button upload i want it to execute my php code and capture its outcome. is this possible? if so how to do it .

if you want to see he code to see if possible here is my php code

           if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
    $fileName = $_FILES['userfile']['name'];
    $tmpName  = $_FILES['userfile']['tmp_name'];
    $fileType = $_FILES['userfile']['type'];
    $fileSize = $_FILES['userfile']['size'];
    $fp      = fopen($tmpName, 'r');
    $content = fread($fp, filesize($tmpName));
    $content = addslashes($content);
    fclose($fp);
    if(!get_magic_quotes_gpc())
    {
        // $fileName = addslashes($fileName);
    }
    $query = "INSERT INTO upload (name, type, size, content) VALUES 
          ('$fileName', '$fileType', '$fileSize', '$content')";
    mysql_query($query) or die('Error, query failed');
    echo "<br>File $fileName uploaded<br>";
    }
user2264202
  • 63
  • 4
  • 9

1 Answers1

2

you can use following to call php pages from your vb.net coding

System.Net.WebRequest
System.Net.WebResponse

Ex : [call a page and get response]

Private Function IsConnectionAvailable(ByVal _URL As String) As Boolean
    'Call url
    'http://www.google.com/
    'http://www.google.co.in/search?sclient=psy-ab&hl=en&site=&source=hp&q=mitac.co.in&btnG=Search
    Dim url As New System.Uri(_URL)

    'Request for request
    Dim req As System.Net.WebRequest
    req = System.Net.WebRequest.Create(url)
    req.Timeout = 5000
    Dim resp As System.Net.WebResponse
    Try
        resp = req.GetResponse()
        resp.Close()
        req = Nothing
        Return True
    Catch ex As Exception
        req = Nothing
        Return False
    End Try
End Function

find how to post parameters to php page here

POST to PHP using VisualBasic?

Community
  • 1
  • 1
Jack Gajanan
  • 1,596
  • 14
  • 18