php上传增加域名
function ajaxfile() {<br /> foreach (lib_request::$files as $filename => $value) {<br /> $picname = lib_request::$files[$filename]['name'];<br /> $picsize = lib_request::$files[$filename]['size'];<br /> if ($picname != "") {<br /> if ($picsize > 1024000) {<br /> echo json_encode(array(<br /> 'code' => '-1',<br /> 'title' => '图片上传',<br /> 'msg' => '图片大小不能超过1M'<br /> ));<br /> exit();<br /> }<br /> $type = get_extension($picname);<br /> if ($type != "gif" && $type != "jpg" && $type != "jpeg" && $type != "png") {<br /> echo json_encode(array(<br /> 'code' => '-1',<br /> 'title' => '图片上传',<br /> 'msg' => '图片格式不对!'<br /> ));<br /> exit();<br /> }<br /> $upload_path = '/up';<br /> <br /> $rand = rand(100, 999);<br /> $pics = date("YmdHis") . $rand . '.' . $type;<br /> $dir = date('/YmdH/');<br /> $pic_path = $upload_path . $dir;<br /> $pic_url = $pic_path . $pics;<br /> if (!file_exists(PATH_ROOT . $pic_path)) {<br /> creatFolder(PATH_ROOT . $pic_path);<br /> }<br /> $PATH_ROOT = PATH_ROOT . $pic_url;<br /> move_uploaded_file(lib_request::$files[$filename]['tmp_name'], $pic_path);<br /> if (request('type') == 'goods') {<br /> makeThumbnail($pic_path, $pic_path . '_290x290.jpg', 290, 190);<br /> }<br /> }<br /> $arr[$filename] = array(<br /> 'name' => $picname,<br /> 'pic' => $pic_url,<br /> 'size' => $picsize<br /> );<br /> }<br /> echo json_encode($arr);<br /> exit();<br />}
<br /><br /> $pic_url = ‘http://www.xxxx.com/’.$pic_path . $pics;<br /><br />