简体   繁体   English

如何将图像从根域保存到子域?

[英]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: 我的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/ . 因此,如果是这样,并且您的脚本位于upload/ ,则可以写入../imgs/ It'd go one directory up to the main public_html , and then enter the imgs subdomain folder. 它将进入主public_html一个目录,然后进入imgs子域文件夹。

It could be like this too: 也可能是这样的:

  • /home/xxxx/[subdomain]/
    If it's like that, you should write to ../../imgs . 如果是这样,您应该写到../../imgs That goes one directory up to public_html , then once again to the parent of public_html , and then to its sibling imgs . 那去一个目录最多public_html再次,然后母公司public_html ,然后被其兄弟imgs

Please note that, depeding on your configuration, the subdomain folder can be anywhere . 请注意,根据您的配置,子域文件夹可以在任何地方 These 2 examples are the most common ones. 这两个例子是最常见的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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