In PHP, I am accessing another user's files using FTP on the same server. In this case, do I need to use secure FTP or is it ok to have normal FTP as both source and destination are on same server?
Thanks.
Related
I have webspace that I can access through ftp. I need a database that I can read and write to remoteley. Is there any way to put a database on a server when the only way I can access that server is through an FTP username and password? I would like to be able to send data from a raspberry pi to this database, then display the data on my website.
There is not one database in the world that you can access the data via FTP directly. FTP is a file transport protocol and most database use their own protocol to communicate with remote users.
For example Microsoft SQL server uses the TDS protocol. MySQL will have its own protocol etc. Another problem you will have is that FTP is extremely insecure. Your user name and password will be hacked if you use this protocol. DO NOT use FTP to transfer sensitive data.
The only way you will be able to let the Raspberry Pi send data to the database is to program it to talk the MySQL protocol. Or to send up a file via FTP and then upload this file with scripts.
I need any site or book which teaches how to use ftp to access remote server in php.
Details of my problem:
Basically there are two servers.All user uploaded files are in server 2 but now I need to access those on my server1.
lets say my ftp details are like this:
ftp://userfiles.example.com
username: admin
password: 1234
then which php function can I use to create a connection to that server. I always accessed files like "../example/dir/example.txt", if there was no password then maybe I could do this
"ftp://example.com/dir/example.txt".
FTP and SFTP (you tagged your post with SFTP and kinda mention it in your question title) are different things. For FTP I'd recommend using PHP's built-in FTP functions. For SFTP.. there's a PHP extension that provides for it (ssh2) but, personally, I think phpseclib, a pure PHP SFTP implementation, is easier to use.
If you're using FTPS (FTP over SSL) then use the FTP extension.
In PHP, i know only how to get the files.
But now i don't know how to do with followings:
How can i distribute/ send/ transfer the files onto another owned Server?
Just to send from the host server. NOT the way to get from the target server.
Please suggest if you know.
Use curl, it support POST http method (if you receive file from html form), and ftp methods (if you had setup ftp server).
If the other servers is yours, you can install a FTP server and use the ftp functions:
http://es2.php.net/ftp
http://es2.php.net/manual/es/function.ftp-fput.php
You can use the curl_XXX functions for this.
How will you recieve the file?
If you have a webserver listening for POST requests, I would recommend cURL.
If you're running some other sort of server I would recommend sending it via sockets.
Yep, you can either install an FTP server on the servers you want to send the data to and then use PHP's FTP functions or use curl, and have a script running on the server you want to send the data to to pick up POST data coming in from the server you're sending the data from.
Hey use php ftp function to transfer files on to the another server.
But make sure that, server given you write permission to edit.
You can go through ftp_fput() method of php to transfer files on
remote server. Go through php manual you will get ready examples for
sending files.
Firstly use ftp_connect() function to connect to remote server.
Then read files from your local directory using file functions and then use fput to put file on to the remote server.
There is a way to list a directory in a remote host without ftp ?
A way using php will be better.
thanks.
No, you can't do that, unless you get some sort of shell access to the remote host, or the remote host provides you with an API to list it (remote API can be an API, or a FILE SERVER FILE SYSTEM access such as NFS or SAMBA).
I'm trying to wrap my brain about how to do this. We need to provide some files within a directory from our servers to our clients' servers via a PHP/Web interface using FTP. I've looked at the FTP capabilities built in to PHP and some custom classes, but someone suggested cURL might be a better option. We will have the FTP login credentials in our database for the application to access. With that information can we use cURL FTP capabilities to do the transfers, knowing our server has libcurl installed, but the clients servers may not? Do both servers have to have it for the FTP function to work?
Or am I completely going about this the wrong way, and have misunderstood how to use cURL and should be looking into an FTP PHP class?
libCURL is a library; it acts as the client.
Your clients need to be running a FTP server but do not need libCURL.
Just to make it super clear, there are 2 computers involved:
Your server, the one that's supposed to provide files to the client using the FTP protocol. That server does not need to have a web server (or PHP) running. The only thing it needs is an FTP server. It also needs to have permissions configured in such a way that there is an account that can access the files through FTP.
Your client's server, the one that's supposed to retrieve files from your server using the FTP protocol. That server needs to have PHP installed, with libCurl. The software on that server needs to access your server using the FTP protocol, providing the user credentials that you configured on your box.
Hope that helps.
It sounds like what you want to do is have the client connect to your PHP script & then push a button to start an FTP transfer that sends a file from your FTP server to their FTP server. If this is the case, then all you need is cURL on your server.