我编写了这段代码用于将文件上传到我的主机。例如,我将文件从服务器 A 上传到服务器 B,然后我想通过我的 PC 下载它,但是当我想下载它时,例如通过 IDM,它是不支持 RESUME 下载。
注意:我将此代码上传到服务器B!
<?php
require('config.php');
function is_valid_url($link)
{
$link = @parse_url($link);
if ( ! $link) {
return false;
}
$link = array_map('trim', $link);
$link['port'] = (!isset($link['port'])) ? 80 : (int)$link['port'];
$path = (isset($link['path'])) ? $link['path'] : '';
if ($path == '')
{
$path = '/';
}
$path .= ( isset ( $link['query'] ) ) ? "?$link[query]" : '';
if ( isset ( $link['host'] ) AND $link['host'] != gethostbyname ( $link['host'] ) )
{
if ( PHP_VERSION >= 5 )
{
$headers = get_headers("$link[scheme]://$link[host]:$link[port]$path");
}
else
{
$fp = fsockopen($link['host'], $link['port'], $errno, $errstr, 30);
if ( ! $fp )
{
return false;
}
fputs($fp, "HEAD $path HTTP/1.1\r\nHost: $link[host]\r\n\r\n");
$headers = fread ( $fp, 128 );
fclose ( $fp );
}
$headers = ( is_array ( $headers ) ) ? implode ( "\n", $headers ) : $headers;
return ( bool ) preg_match ( '#^HTTP/.*\s+[(200|301|302)]+\s#i', $headers );
}
return false;
}
if (isset($_POST['pass']) && isset($_POST['user'])){
if ($_POST['pass'] == $pass && $_POST['user'] == $user){
if (!$pass | !$user | !$save | !$link){
include('./error.php');
}elseif(is_valid_url($link) && copy($link, $upload_folder.'/'.$save)){
include('./index.2.php');
}else{
include('./error.php');
}
}else{
include('./error.php');
}
}
?>
谢谢你的帮助 ...