Frage

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);
War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top