How to Upload images in the Admin Domain, and Save them in images folder in another domain (blog)?

Here is my problem, I have two domain names, lets say, (users domain) and (admin domain). They are using the same database.
I upload everything from the admin website and save in the common database, where the other site, is fetching from. My problem comes when am uploading images to be used by x. Here is what I want to do, I want to upload images in the admin website, save the image in the images folder in the other site. and save the link to the database. The link is saving correctly but the image is not uploaded.
Is what am trying to do possible? And if yes, how can I achieve that?
Your help will be highly appreciated.
Thanks in advance.

  • Is the stored URL has correct structure? (e.g.: http://mysecondary-web.tld/my_path/uploaded_stuff/myImage.png; or similar to). Please note that you can’t use relative-type URL when accessing stuff outside your web/server, regardless of its ownership

  • If image wasn’t uploaded, you may want to check the $_FILES, and its upload form. See if you can find what causes them unable to be stored in your server.

In case of confusion, please refer here: PHP File Upload

Update: I hope this post is still relevant

Hotlinking may still prohibited here, sorry :smiley:

It’s not possible for scripts on one domain to access files on another domain, even within the same account. So scrips on cannot access files on and vice versa. I think that makes it quite hard to do what you’re trying to do on free hosting.

Some workarounds which might help (outside of upgrading, of course):

  • Move both services to the same domain and use sub paths to separate areas (e.g. for users and for admins).
  • Store the files in the database as BLOB cells (quite bad for performance - not recommended).
  • Store the files on an external file storage.
  • Build an upload endpoint for admins in the user site so files are only stored on the user site. Or vice versa. Or on a separate subdomain. Plenty of options here. Just keep in mind that you can’t embed stuff from a different domain, so keep that in mind on which domain you want to serve the files form.