Upload file from local server to web server using codeigniter - php

I have a client database that generates and stores reports on a local server and I would like these reports to be able to be accessed by a publicly accessible remote server.
The local server runs windows, and I am running a unix installation on the remote server.
The public side is built with codeigniter, and the local side is proprietary php code. How would I go about transferring files onto the remote server?
I am not looking for somebody to write the code for me, but if you could provide a general example, or point me in the right directon it would be greatly appreciated.

You can use CURL to send file in background to local server to other server, Here is good example.
How to send upload file to other website by using curl in php?

I ended up installing winSCP on my local windows server, then from the php file using shell_exec to call a batch file with commands to transfer the file.

Related

What is the best and easiest way to access files within a linux vps using its external ip?

I have a game server running in a vps with centos 6 .
The game server stores its status data on a text file and i want to access this file from my website server with php.
The problem is that it is better to do it without installing something link ftp server on the vps. Also i do not know how to set the ftp account directory to my game server directory.
Anyone knows any other simpler way to do so ?
Thanks.
Use a client which supports SFTP if you are able to connect to your server via SSH.
phpseclib handles the SFTP connection without the need to install an extension. For an example on how to download a file with SFTP go here.
If you don't have a webserver installed on your vps, you can use an sftp connection with php, check this question to help you implement it.
sFTP being available by default on most linux OSs you shouldn't have much trouble doing this;

How to access xampp server?

I installed XAMPP server in a rackspace cloud server. Now I want to access it from my local PC, like accessing web server through IP and coding & executing. Any solution would be grateful received.
If you want to connect to remote server from local machine, then
you can use PuTTY - http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Here is a brief tutorial on how to use it:
http://www.gamexe.net/other/beginner-guide-ssh/
or you can search for another one.
There are many articles about PuTTY.
How about using FTP to write your code and execute. I work directly off my server I use Netbeans as my IDE of choice and it has a ftp feature that lets you work with files directly off your server.
Is that what you meant when you wrote:
web server through IP and coding & executing

Creating a file in client machine

Is there any possbile solutions in PHP to create a file or directory on the client machine.
Note:
Downloading the file is not a solution to me. only once the user access the website and execute some function and it allows to create a files or directory on the client machine.
Simply, you can't do that in php or any other server side language.
Reason is simple server side application and scripts have access only to local resources where they are launched. So when you run your application on local computer, everything works as you wish for. But because of how HTTP works and because of safety reasons you cannot access user local files.
No it's not possible , except- Flash, Applet ( Not sure ), Microsoft Silverlight ! and for those you will also have to give permission. But i don't think it is a good idea to store file on client machine, try another :)

Upload files on file server in intranet in php

I am maintaining two local servers on local network (within the office premises).
One is the server where my php files are being located and another server is a File Server where I want to store all the uploaded files.
As the second one is a file server so there should no need to install php on that server.
How I can upload the files to another server. I have the full rights to access the file server. I tried to use ftp_connect() method. But that is not working in Intranet however, it is perfectly working with any live server ftp credentials.
If I use CURL then I have to install PHP on my file server, but that is not a good practice. So how I can upload the files using php ftp related methods?
How I can upload the files to file server. Thanks in advance.
Since in your case both client and server are Unix systems, the easiest is to mount a directory of the file server on the web server by NFS. This way you can upload files by copying or moving them locally, no need to muck around with FTP or SSH modules in PHP.

php file_get_contents ('....datafile.xml') - get the datafile from my local desktop?

I have a database that exports xmls only locally (to my computer). It will not export to a remote server.
I have a php file (located on remote server) that sends the xml to a webserivce.
Can I have the remote php file use "file_get_contents" function to extract xml data from my local computer?
If so, what is the proper syntax?
Thanks in advance.
I think you should add a file upload page,upload the local xml file to remote server,the do the the next work.
You have a couple of options...
You could run a local web server on your computer and publish the files via that. Your remote PHP script could then read the file.
A potentially better alternative would be to use something like Dropbox. Save the database files in your Dropbox folder. They will be automatically uploaded to the Dropbox cloud storage.
Your remote PHP script could then retrieve them via the Dropbox API or if they are in the "public" folder, directly via URL.
You have to make your file available from your linux machine:
install a webserver on your desktop machine and allow it to expose the file, so the file will be available to an URI like http://ip_of_your_desktop/path_to_files/filename.xml (this was mentioned above also)
if your desktop and server are on the same network, share the folder on your desktop, mount the folder on your linux machine and use file_get_contens to read the file from the mounted location

Categories