PHP程式碼
//下載遠端檔案 function download_remote_file($file_url, $save_path) { $file_name = substr($file_url, strrpos($file_url, '/') + 1); if (strpos($file_name, '?') > 0) $file_name = substr($file_name, 0, strrpos($file_name, '?')); $save_to = $save_path.'/'.$file_name; $fp = fopen ($save_to, 'w+'); $ch = curl_init(); curl_setopt( $ch, CURLOPT_URL, $file_url ); curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, false ); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false ); curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 10 ); curl_setopt( $ch, CURLOPT_FILE, $fp ); curl_exec( $ch ); curl_close( $ch ); fclose( $fp ); return $save_to; }
0 意見:
張貼留言