php上传增多域名

WBOY
Release: 2016-06-13 12:20:16
Original
867 people have browsed it

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 />}
Copy after login





以上上传后得到的路径是/up/xxxxx/xxxxx.jpg
我想修改为:http://www.xxxx.com//up/xxxxx/xxxxx.jpg


------解决思路----------------------
估计是想得到一个改变的url ?
<br /><br /> $pic_url = ‘http://www.xxxx.com/’.$pic_path . $pics;<br /><br />
Copy after login


是这样么?提问说的不清晰 哈哈。
------解决思路----------------------
你说的是什么意思??不是很明白
如果是数据库里面的路径 你update就可以了
如果是上传到其他服务器的,这应该不行把

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!