好吧所以我正在努力将文件上传到数据库,我在php中编写了上传部分。但我希望vb执行它。我会在vb中写它但我不是最好的vb程序员因为我刚开始使用它。所以我想要的是当用户点击按钮上传时,我希望它执行我的PHP代码并捕获其结果。这可能吗?如果是这样的话。
如果你想看到他的代码,看看这里是否有我的PHP代码
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>";
}
答案 0 :(得分:2)
您可以使用以下命令从您的vb.net编码中调用php页面
System.Net.WebRequest
System.Net.WebResponse
Ex:[调用页面并获得回复]
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
找到如何将参数发布到php页面