So, here is the setup I have to work with:
I have five servers total in different locations. One server is purely a web server for hosting static files. The other four servers are solely FTP servers, each containing files uploaded by users through PHP scripts.
What I want to do is be able to choose the server with the most free space available and send the next user-uploaded file to it. I've searched around, and there doesn't seem to be any way to do that with only FTP commands.
I found a question about Determining the Free Space of an FTP Server, which showed that it was possible to create and update a file periodically with a Linux Shell script, but, the servers I have are and will stay Windows machines.
My only solution would be to host web servers on the FTP servers with a simple index.php containing the remaining filesize determined by disk_free_space()
but that seems a bit much for something so simple.
All that I'm looking for is a way to find out this information with FTP commands, or possibly be able to link the servers to a VPN somehow and use PHP to figure out the amount of free space, though I wouldn't know exactly how to do that, or even, if it would work...
Thanks to anyone in advance!
If you are using IIS FTP server on the Windows machine, you can configure the IIS to include free disk space in the
LIST
command response.In the IIS manager, go to your FTP site, and select FTP Directory Browsing applet. There, in the Display following information in directory listing setting, check the Available bytes.
Then, the
LIST
FTP command response will look like:You can test this with WinSCP FTP client, it can make use of this information. Just go to the Space available tab of the Server and Protocol Information dialog.
(I'm the author of WinSCP)
Other FTP servers support other ways to retrieve free disk space.
See How to check free space in a FTP Server?