url_short; } return $arr;}function downfile($fileurl) { ob_start(); $filename = $fileurl; $date = date("Ymd-H:i:m"); header("Content-type: application/octet-stream "); header("Accept-Ranges: bytes "); header("Content-Disposition: attachment; filename= { $date}.txt"); $size = readfile($filename); header("Accept-Length: " . $size);}set_time_limit(0);if (!empty($_POST['submit'])) { if ($_FILES['file']['error'] == 0) { if ($_FILES['file']['type'] == 'text/plain') { $baseurl = dirname(__FILE__)."/upload/"; $url = $baseurl . getMulu(); if (!is_dir($url)) { mkdir($url, 0777, true); } $file_dizhi = $url . mtrand(); $rs = move_uploaded_file($_FILES["file"]["tmp_name"], $file_dizhi.'.txt'); if ($rs) { //读取文件 $file = fopen($file_dizhi.'.txt', "r"); $xieru_txt = ''; $num = 0; $temp_url = ''; while (!feof($file)) { $temp_url .= '&url_long='.urlencode(trim(fgets($file))); $num++; if($num%20 == 0){ $rs = shortenSinaUrl($temp_url); $xieru_txt .= implode("\r\n", $rs); $xieru_txt .= "\r\n"; $temp_url = ''; } } fclose($file); file_put_contents($file_dizhi.'_xieru.txt', $xieru_txt); downfile($file_dizhi.'_xieru.txt'); exit; } } else { echo '请上传txt文件'; } } else { echo '上传失败'; }}?>短网址服务