php上傳增多網域名稱

來源:互聯網
上載者:User
php上傳增加網域名稱
function ajaxfile() {
foreach (lib_request::$files as $filename => $value) {
$picname = lib_request::$files[$filename]['name'];
$picsize = lib_request::$files[$filename]['size'];
if ($picname != "") {
if ($picsize > 1024000) {
echo json_encode(array(
'code' => '-1',
'title' => '圖片上傳',
'msg' => '圖片大小不能超過1M'
));
exit();
}
$type = get_extension($picname);
if ($type != "gif" && $type != "jpg" && $type != "jpeg" && $type != "png") {
echo json_encode(array(
'code' => '-1',
'title' => '圖片上傳',
'msg' => '圖片格式不對!'
));
exit();
}
$upload_path = '/up';

$rand = rand(100, 999);
$pics = date("YmdHis") . $rand . '.' . $type;
$dir = date('/YmdH/');
$pic_path = $upload_path . $dir;
$pic_url = $pic_path . $pics;
if (!file_exists(PATH_ROOT . $pic_path)) {
creatFolder(PATH_ROOT . $pic_path);
}
$PATH_ROOT = PATH_ROOT . $pic_url;
move_uploaded_file(lib_request::$files[$filename]['tmp_name'], $pic_path);
if (request('type') == 'goods') {
makeThumbnail($pic_path, $pic_path . '_290x290.jpg', 290, 190);
}
}
$arr[$filename] = array(
'name' => $picname,
'pic' => $pic_url,
'size' => $picsize
);
}
echo json_encode($arr);
exit();
}





以上上傳後得到的路徑是/up/xxxxx/xxxxx.jpg
我想修改為:http://www.xxxx.com//up/xxxxx/xxxxx.jpg


------解決思路----------------------
估計是想得到一個改變的url ?


$pic_url = ‘http://www.xxxx.com/’.$pic_path . $pics;



是這樣嗎?提問說的不清晰 哈哈。
------解決思路----------------------
你說的是什麼意思??不是很明白
如果是資料庫裡面的路徑 你update就可以了
如果是上傳到其他伺服器的,這應該不行把
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.