Add domain name for php uploads

Source: Internet
Author: User
Add domain name for php uploads
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' => 'image upload ', 'MSG '=>' the image size cannot exceed 1 MB '); exit () ;}$ type = get_extension ($ picname); if ($ type! = "Gif" & $ type! = "Jpg" & $ type! = "Jpeg" & $ type! = "Png") {echo json_encode (array ('code' => '-1', 'title' => 'image upload ', 'MSG '=>' the image format is incorrect! '); 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 upload path is/up/xxxxx/xxxxx.jpg.
I want to change to: http://www.xxxx.com//up/xxxxx/xxxxx.jpg


Reply to discussion (solution)

$ Upload_path = '/up ';???

Do you store images outside the website?
In this case, the url cannot be used for access.

Is it estimated that I want to get a changed url?

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


Is that true? The question is unclear.

What do you mean ?? Not very clear
You can update the path in the database.
If it is uploaded to another server, this should not work

$ Upload_path = '/up ';???

Do you store images outside the website?
In this case, the url cannot be used for access.



The up Directory is under this website, but I have bound a domain name to the up Directory.

Up Directory foreground path is http://www.xxx.com/up/
Can also be: http://img.xxx.com/up/
The uploaded file is/up/xxxxx/xxxxx.jpg.
The front-end display path is http://www.xxx.com/up/xxxxx/xxxxx.jpg
So the path I want to display on the front desk is http://img.xxx.com/up/xxxxx/xxxxx.jpg


I have also changed the modification like on the second floor. I can get http://img.xxx.com/up/xxxxx/#, but there are no images under this picture.

Is it estimated that I want to get a changed url?

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


Is that true? The question is unclear.



I have also changed this, but after the change, there is no file in this path

You cannot. You need to upload this item to this server.
I thought you just changed a url. Add group I will tell you in the group. 231566327

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.