How can i use opendir function to read the directory list of a remote server knowing its IP address?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you are trying to access the remote server using HTTP, you won’t be able to do this directly. Since HTTP is really going access the web service of your remote server, it controls how the files are presented to you. In the case of many web servers, you can turn on “indexes” for folder contents. This causes the entries in the folder to be displayed in your browser as HTML. In order to traverse the directory structure, you would need to parse this HTML to find the path information.
If you are using FTP, you can pass the
ftp://...URL toopendir()as of version 5.0. Note that this capability can be turned off by your server admin. If you cannot use this feature directly, see the FTP functions manual for PHP (includingftp_nlist()for listing files).An example from the above references: