PHP Upload Add domain name

Source: Internet
Author: User
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 (' C                Ode ' + '-1 ', ' title ' + ' picture upload ', ' msg ' = ' picture size cannot exceed 1M ');            Exit ();            } $type = Get_extension ($picname); if ($type! = "gif" && $type! = "jpg" && $type! = "JPEG" && $type! = "png") {Echo J Son_encode (Array (' Code ' = '-1 ', ' title ' = ' picture upload ', ' msg ') = = ' picture is not in the right format!                '                ));            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 ();}





The path obtained after uploading is/up/xxxxx/xxxxx.jpg
I would like to change to: http://www.xxxx.com//up/xxxxx/xxxxx.jpg


Reply to discussion (solution)

$upload _path = '/up ';???

Do you store the pictures outside the website?
This is not a URL to access the

An estimate is to want a change URL?

$pic _url = ' http://www.xxxx.com/'. $pic _path. $pics;


Is that so? The question is not clear haha.

What do you mean by that? I don't understand.
If it's the path inside the database, you can update it.
If it is uploaded to a different server, this should not be

$upload _path = '/up ';???

Do you store the pictures outside the website?
This is not a URL to access the



The up directory is under this site, but the up directory I am also binding a domain name

Up directory The foreground path is http://www.xxx.com/up/
Also available as: http://img.xxx.com/up/
Now the path to the upload is/up/xxxxx/xxxxx.jpg
The path shown in the foreground is http://www.xxx.com/up/xxxxx/xxxxx.jpg
Then I think the path shown in the foreground is http://img.xxx.com/up/xxxxx/xxxxx.jpg


Like the second floor so modify I also changed, can get http://img.xxx.com/up/xxxxx//path, but there is no picture under the path

An estimate is to want a change URL?

$pic _url = ' http://www.xxxx.com/'. $pic _path. $pics;


Is that so? The question is not clear haha.



I've changed that, too, but after the change, there's no file on the path.

I'm sure you can't do that. You need to upload this thing to this server.
I thought you were simply changing a URL address. Add Group I'm telling you in the crowd. 231566327

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.