有興趣可以先看上一篇文章,然後這兩個是關聯的。不同的圖片,對應不同的typeID,<?php <br />
<br>
/*<br>
* time:2016年12月2日17:21:37<br>
* 功能:根據文字裡面的roomID和資料夾下面的檔案配對上傳到伺服器<br>
* 主要參數說明:$file_qqq 圖片檔案路徑<br>
* $r roomID,並獲得一個陣列循環一次出隊取得此參數<br>
* $type 以以上傳方式使用方式<br>
*author:zhangchenyang<br>
*/<br>
ini_set('max_execution_time', '0'); //設定逾時時間<br>
header('content-type:text/html;charset=utf8');<br>
<br>
<br>
$act = $_GET['pass'];<br>
if ($act == 'zhangchenyang') {<br>
/**<br>
*time:2016年12月2日16:09:33<br>
* 注意:1:圖片路徑是否正確<br>
* 2:房間id是否對應<br>
*<br>
*/<br>
$file = './room400.txt'; //上傳的roomID檔案<br>
$content = file_get_contents($file);<br>
//echo $content;<br>
<br>
$array = explode("rn", $content); //轉成陣列<br>
//地櫃列出所有文件<br>
function tree($directory)<br>
<br>
{<br>
global $array;<br>
$mydir = dir($directory);<br>
<br>
echo "<ul>n";<br>
<br>
while ($file = $mydir->read()) {<br>
<br>
if ((is_dir("$directory/$file")) AND ($file if ((is_dir("$directory/$file")) AND ($file != ".") AND ($file != ".."))!= ".") AND ($file !=
$arr = array_shift($array);<br>
<br>
echo "<li><font><b>$file</b></font></li>n";<br>
<br>
tree("$directory/$file");<br>
<br>
} else<br>
<br>
<br>
global $arr;<br>
if (is_dir('$file')) {<br>
<br>
} else {<br>
<br>
<br>
if ($file !== '.' & $file !== ".." & $file !
$img_name = mb_substr($file, 0, 1, 'utf-8');<br>
if (is_numeric($img_name)) {<br>
echo "<li>$file,$img_name</li>n";<br>
$file_qqq = "$directory/$file";<br>
var_dump($file_qqq);<br>
//建置介面的參數<br> $r = $arr;<br>
$t = $img_name;<br>
<br>
$return_data = up($file_qqqq);
if ($return_data == '200') {<br>
//上成功型<br>
$ok_info =
file_put_contents('ok400.txt', $ok_info, file_put_contents('ok400);
<br>
} else {<br>
$err_info =
file_put_contents('error400.txt', $err_info
<br>
<br>
}<br>
<br>
<br>
}<br>
<br>
}<br>
}<br>
<br>
<br>
}<br>
<br>
echo "</ul>n";<br>
<br>
$mydir->close();<br>
<br>
}<br>
<br>
<br>
echo "<h2>目錄為粉紅</h2>
<br>n";<br>
<br>
tree("./img400");<br>
function up($file_qqq, $r, $type)<br>
{<br>
<br>
$u = '1';<br>
$t = '1';<br>
<br>
<br>
$ch = curl_init();<br>
$source = $file_qqq;<br>
$source = realpath($source);<br>
//加@符號curl就會把它當成是檔案上傳處理<br>
$data = array('img' => '@' . $source);<br>
//$url='http://localhost/update_admin.php?u=%s&t=%s&r=%s&type=%s'; /測試介面<br>
$url = 'http://localhost/room/update_admin.php?u=%s&t=%s&r=%s&type=%s';<br>
$url = sprintf($url, $u, $t, $r, $type);<br>
//var_dump($url);<br>
$cfile = curl_file_create($source, 'image/jpeg', '1.jpg');<br>
<br>
// 設定 POST 資料<br>
$data = array('uploadedfile' => $cfile);<br> $ch = curl_init($url);<br>
curl_setopt($ch, CURLOPT_URL, $url);<br>
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);<br>
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不驗證憑證<br>
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //不驗證憑證<br>
curl_setopt($ch, CURLOPT_POST, true);<br>
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);<br>
$結果=curl_exec($ch);<br>
//var_dump($data);<br>
$錯誤= curl_error($ch);<br>
$b = curl_multi_getcontent($ch);<br>
curl_close($ch);<br>
<br>
<br>
返回 json_decode($結果);<br>
<br>
}<br>
<br>
<br>
} 另外 {<br>
<br>
echo "<script>alert('你的口令有誤請重試')</script>";<br>
}