简体   繁体   中英

How to save an image to a subdomain from the root domain?

I need to upload an image and save it to a subdomain. Is it possible to do that if the upload script is in the root? This are the file paths: Upload script:

https://www.example.com/upload/save.php

Image Storing:

http://imgs.example.com/temp

My PHP:

 $tempFolder = 'tempimages/';
    $fh = fopen($tempFolder.$filename, 'w') or die("can't open file");
    $stringData = base64_decode($base64image);
    fwrite($fh, $stringData);
    fclose($fh);

Usually, the structure for a website with subdomain is this one:

  • /home/xxxx/public_html/[subdomain]/
    So if it's like this, and your script is in upload/ , you could write to ../imgs/ . It'd go one directory up to the main public_html , and then enter the imgs subdomain folder.

It could be like this too:

  • /home/xxxx/[subdomain]/
    If it's like that, you should write to ../../imgs . That goes one directory up to public_html , then once again to the parent of public_html , and then to its sibling imgs .

Please note that, depeding on your configuration, the subdomain folder can be anywhere . These 2 examples are the most common ones.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM