I used to transfer temporarily-direct-linked files to my server because my internet speed is not as much as my server. The method I'm using (fread) only works with http protocol. But I can not even get connected to files accessible using RTMP protocol using fopen. Could you tell me what can I do to get around this?
Cheers
You might be able to use curl - this can be compiled with librtmp support. Not sure if it's supported within the PHP curl extension, but you could simply use curl as a separate process.
Related
I have some PHP code in which XML data is being passed between server and client using sockets. socket_create( AF_INET, SOCK_STREAM, SOL_TCP ), socket_read(), socket_write() are the functions being used to pass XML and not HTTP requests.
Now if I want to use a proxy for client to use to connect through to the server, how can I do that in PHP?
I am new to sockets and from what I have gathered, there exists this library https://github.com/clue/php-socks which I don't fully understand right now but the idea is to setup the middleman using the same library which is essentially the proxy in this case. How would I go about using a SOCKS4/5 proxy obtained from https://www.socks-proxy.net/ or paid ones? Is the above mentioned library the only option? Feels like PHP should have something built in already.
Please advice.
This should be a comment, but it's a bit long.
Feels like PHP should have something built in already
I'm struggling to imagine why it should. PHP is a language designed for serverside web development. Proxies are a client side technology. Having said that the curl extension has comprehensive support for HTTP proxies.
There is no single proxy protocol. Certainly SOCKS and HTTP are the most visible protocols for proxies but there are lots more. Was there a specific reason for choosing SOCKS?
If it were me I would just setup transparent port forwarding using iptables (Linux) or a socat instance or haproxy (Unix, MSWindows).
When someone comes to my website via url: http://domain.com/FILE_ID, PHP would connect to the ftp server and get FILE_ID and then stream it to client without saving it on the local server. I don't want to provide my clients with a link to my file on ftp server instead I thought of this.
Does anyone have an idea how I can accomplish this?
I was thinking I could use "ftp_get()" method to get the file from ftp but that requires me to write in on a local server(or am I wrong?). After that use PHP headers to force the download.
Basically any and every piece of information would be useful. Just so I can start walking in the right direction.
What you are after is the Curl library - as it can handle FTP. See this, it has an FTP example.
Alternatively, if you've got a server that has URL bindings for file_get_contents, you can use
file_get_contents("ftp://username:password#server/path/to/file.ext");
to get the contents of a remote file on an FTP server.
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.
I'm looking for the best method to work with an FTP server over an SSL connection. (Generally, pushing a file up as well as getting a list of files on the server). One requirement for this project is that I must use a client side X.509 certificate as part of the authentication process.
Can I use a client certificate using the php function ftp_ssl_connect. If so, how? The only other option I've been able to identify would be using curl to work via FTPS.
Any suggestions or thoughts would be greatly appreciated!
You could use PHP's stream context functions which allow setting SSL client certificates. Use the created context with standard functions like fopen.
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.