I am using PHP curl to capture files from a URL. The file names are currently hard coded and I am trying to create it so that it can download all the files in a specific directory. Any point in the right direction would be good. Thank you.
Please note that I have a "read" right in a directory, I do not have FTP access or anything else.
Server_url: http://192.168.2.45 / Logfiles / server: server1 Files in that directory: 140512 ... 150316.log and increasing & lt ;? Php $ server_url = $ _GET ['server_url']; $ Server = $ _GET ['server']; // It needs to be changed for all files ($ i = 140512; $ i & lt; = 150316; $ i ++) {$ id = base64_encode ($ i); $ File_name = $ server_url $ I ' Log '; Curl_setopt ($ ch, CURLOPT_URL, $ file_name); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, 1); // return data string as idle peer verification curl_setopt ($ CH, CURLOPT_SSL_VERIFYPEER, FALSE); // // disabled host verification curl_setopt ($ CH, CURLOPT_SSL_VERIFYHOST, incorrect); // Real Browser Client String Curl_setopt ($ CH, CURLOPT_USERAGENT, "Mozilla / 4.0 (compatible; MSIE 5.01; Windows NT 5.0)" Spoof; $ output = curl_XC ($ CH); // Capture data in output variable if (! DIR ('sites /'. $ Server. '_ LOGS')) {MKDIR ('sites /' .a server. '_ LOGS');} If ($ output! = False) {file_put_contents ('sites /'. $ Server. 'LOGS'. '/ U_ex'. Base64_decode ($ id). '.log', $ output);} Curl_close ($ ch);}? & Gt;
Curls supports FTP, You can use it to make a file and then download each file. I found an example using PHP curls in the previous answer.
No comments:
Post a Comment