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>";
    }

1 Answer 1

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?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.