How can I upload images to another host domain with php? - php

My admin panel is on test.com and I have functionality in my admin panel that allows the uploading of images. But the images must be uploaded to subdomain.test.com.
My server is CentOS 7.2 minimal and I installed DirectAdmin on server.
What is the best solution for this issue?

As per my understanding and experience it is not possible to direct upload, but following are some way to achieve this.
In your case, as you are looking to upload/save the images to sub domain created under that domain as mentioned by you. You can upload the file to your main domain and then move the images to your sub domain file using server root paths. It is easy to implement as you just want to save image on your subdomain.
Define some web service application on your subdomain which will read the images through bystream passed from main domain. i.e your main domain will call web services of subdomain to save the images. (It will require extra efforts)

Related

Add standalone PHP web application to existing site

There is a running website (on Bitrix CMS) located on the simplest shared hosting with cPanel. The task is to create a standalone little web application in PHP (for internal use in the company), which, for simplicity, will be available from the same domain, but, what is important, it will not affect the already running site.
On the hosting, in the file manager, there is a public_html folder - as I understand these are the site files. I created in public_html a subfolder (for example, webapp) and added a couple of test files (for example, test.txt). The test file is supposed to be available at site.com/webapp/test.txt, but nothing is loaded - just a white screen, no error messages.
Trying with text files and simple php-scripts - the same result, just white screen.
How to fix it?
Check your .htaccess on site root, it maybe redirecting all routes to index.php of Bitrix CMS.
Alternatively you can follow above answer and create a subdomain.
Simple tutorial here.
You can create a subdomain and point your public_html folder there.
You need to create an Index.php file in the subdirectory, in hosting any folder must have this file which will be executed any time you access that directory with URL.

Main website and Subdomain Mobile Website (facing user directories issue)

I have main website on one domain and now I am working for m.domain.com (mobile sub-domain).
On my main website users register themselves and a directory is automatically created in website.
Now as I am working on different directory for m.domain, users register themselves and directory is created in m.domain, but it is not created in main website. So i am stuck.
I want to have common user's directories even when they login from main domain or m.domain.com
Here's image:
Do not use different directories for your domains.
You have (at least) two options:
configure your web server so that both domains (domain.com and m.domain.com) point to the same directory (e.g. virtual hosts - refer to your web server documentation)
configure URL redirects, so that any m.domain.com/page.php actually opens domain.com/page.php?mobile=1, where mobile=1 is a GET parameters.
In both cases, you have one set of PHP scripts, and the script can deliver the main/mobile content dependent on how it was called (either m.domain.com or due to a mobile GET parameter).

Set url to level above installation directory Wordpress

I don't know if it is even possible so that's why I put my question here.
We have a webserver running a PHP application build within the Yii-framework and we have also integrated Wordpress into that application.
The root contains the Yii-application and a dir with the wordpress installation. Now I would like to know if it's possible to create a page and have it a url outside it's installation dir.
An example:
domain.com shows the Yii application index
domain.com/blog shows the Wordpress homepage
Now I want to create domain.com/foobar and the page foobar comes from Wordpress.
Is it possible and how?
Kind regards,
Pim
Your server will have been setup with your domain name. I don't know if you are using a hosted service, or a cloud based option, but either way you should be able to tell your web server to load different index.php files based on the URL.
Every single web request comes through your web server. You can tell your web server to load different php files depending on the http request URL.
For example, when you setup your sever with domain.com you would have had to (or in most cases its the default) tell your web server to route all domian.com requests to /public/index.php
Following this logic, if you want to load a different index.php file from a different URL, you just have to set this up in your web server. So domain.com/foobar would point to /some/directory/public/index.php
The way you do this very much depends on your server and if you have some server admin software installed e.g. cPanel.

Opencart admin section on another server

Is there any way to have the admin area of open cart located on my own server and have it accessible from there while having everything else located on the client's server and using the same database (which would be located on the client's server as well)?
I know all the admin files are located in the admin folder it can't be as simple as just uploading those files to my server, is it? I'll be using Opencart 2.0.
The theoretical answer to this is yes, you can.
You'll need to have the system folder on both servers since both the admin and catalog rely on the base classes to run.
On your client server you'll need:
catalog/*
config.php
crossdomain.xml
image/*
index.php
install/*
php.ini
system/*
On your admin server you'll want to make the normal admin folder your document root. So instead of adminserver.com/admin you'll just use adminserver.com
Admin server setup:
config.php
controller/*
index.php
language/*
model/*
view/*
php.ini
system/*
Then in your adminserver/config.php you would simply adjust you paths and db info as appropriate.
But the "real world" answer to this in no, you can't.
If you did do this, one of the main controllers in the admin area, file manager would not work.
File manager relies on the public images folder to upload images for your products. On a separate server the file manager would attempt to upload images to image/data which you could create on your adminserver, but obviously this wouldn't carry over to your client server.
You'd need to FTP your images to the client server with the exact same name and route as the admin server. Plus this could be extremely problematic for extensions. How would you set up modifications? Or extensions that have image parameters?
If maybe you had a CDN module in place, that might resolve the issue ... tough to say for sure.
Just keep in mind, once you've completed the install, you can change the config paths to whatever you like.
You don't have to use admin as your admin area, you can change it to steve or aardvark or whatever you like in the config file.
Having it on a separate server would be ideal, but for OpenCart, it's really not practical in a real world environment.

Upload a photo to another domain

I have a number of different domains where I would like users to be able to select a photo, however I want to photos uploaded/stored on one central separated domain.
Is there a more advisable way to do this?
I've considered using an iframe from the other domain (so they are interacting with the required domain) but haven't tried it yet.
I have also read that curl can potentially do this.
Any other ideas/problems/concerns...
All advise appreciated.
thx
There are a couple ways you can handle this. Here are the scenarios I see.
Scenario A:
All domains are on the same server. With this setup you can actually help your server security by storing the images and other files in a directory that is not accessible by Apache. Then you use PHP to serve the file to the end user through virtual links. Drupal does this with its private file system.
If the users are able to upload images from the other domains then just have all of the domains write the images to the same directory, but then always return the "central" domain's URL for retrieving them.
Scenario B:
The domains exist across two or more servers. With this setup what you really need to do is setup an API where the other domains communicate behind the scenes to send the photo to the core repository domain. This domain saves it and returns a URL for accessing it.
In either case you should really look up CDN technology. Its basically what your trying to accomplish plus a lot more. I would also recommend that in either scenario that you always use the path on the central domain for all the images instead of returning them back through the current domain.
No reason to get iframes or curl involved. Assuming that all these domains are on the same server (or same cluster of servers), there is nothing which requires that a file uploaded using a file on one domain must only be served from that domain. An upload form can do whatever it wants with the uploaded file, including storing it in a location where it'll be available from your central domain.

Categories