所以,如果你想在 PHP 中这样做,你可以使用以下代码:
<?php
//Filepath is the full url to your file
$filepath="http://www.example.com/examplefile";
//Filename is the name you want to display for the file, even if the files name is "1" you can set the name to be "2"
$filename='Example Name Here';
//The files description:
$filedescription='This is my example file';
//The first line here contains the filetype of the file, so that it can be open correctly.
//This example is .pdf, but you can use other filetypes - as told later on
//This following "block" contains information about the file
header('Content-Type: application/pdf');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=" . $filename);
header("Content-Description: $filedescription");
header("Content-Length: " . filesize($filepath));
//Download the file
readfile($filepath);
?>
如果您的文件不是 .pdf,请在此处查看不同文件类型的完整列表:
http ://webdesign.about.com/od/multimedia/a/mime-types-by-content-type.htm
因此,如果您的文件是 .jpg,则代码应该是;
header('Content-Type: image/jpeg');
代替;
header('Content-Type: application/pdf');
所以......这个脚本将做的是,当它从浏览器打开时,它会获取您尝试下载的文件,并在下载之前更改信息。该文件可以上传到网络服务器或(不确定)保管箱帐户。
VB代码应该是:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
//The url should be the one to your .php file
Process.Start("chrome.exe", "http://example.com/example.php")
End Sub
我现在如果你不习惯 php 等,这可能会很模糊,但不要害怕 - 我会帮助你!如果有什么问题,请发表评论;)