Cara menggunakan php download remote file

Pada panduan ini, kami akan berbagi cara remote database MySQL dengan aplikasi Navicat. Aplikasi ini dapat anda download melalui website resmi Navicat.

Daftar Isi

Sebelum kami menjelaskan tentang cara menggunakan remote database di hosting dengan navicat, terlebih dahulu kami akan menjelaskan secara singkat apa itu aplikasi Navicat. Berikut informasi selengkapnya.

Apa itu Navicat?

Navicat adalah software untuk mengelola berbagai macam database, salah satunya MySQL dan bisa digunakan untuk remote database mysql secara GUI (Graphic User Interface), dimana kita bisa mengkonfigurasi database secara grafic atau dengan secara instan menginstall dan konfigurasi tanpa harus menggunakan script.

Aplikasi Navicat ini digunakan untuk memanipulasi data MySQL, seperti membuat database, membuat tabel, menghapus tabel, dan navicat bisa di gunakan untuk mengubah tipe data MySQL yang biasanya berakhiran (.sql) ke dalam format file Paradox (*.db), file DBase (*.dbf), file Text (*.txt), file HTML (*.htm;*.html), file Excel (*.xls), file Excel 2007 (*.xlsx), file Lotus 1-2-3(*.wk1), QuattroPro (*.wq1), file XML (*.xml), database MS Access (*.mdb).

Remote Database dengan Navicat

Berikut adalah langkah-langkah remote database dengan aplikasi Navicat.

Step 1. Tools yang diperlukan

  • Aplikasi Navicat ini terdapat versi yang bisa di download secara gratis dan berbayar/premium.
  • Fitur remote database tersedia untuk paket Medium dan Large di layanan Share Hosting. Sedangkan untuk layanan Cloud hosting, semua paket telah support remote database.
  • Sebelum Anda melakukan remote database, silahkan request whitelist IP terlebih dahulu ke email teknis[at]rumahweb.com, dengan menyertakan nama domain beserta IP public koneksi yang digunakan.

    Apabila IP public Anda dinamis, kami sarankan agar Anda menggunakan layanan Dynamic IP address (DDNS) yang bisa didapatkan dari pihak ketiga seperti noip.com.

Step 2. Cara remote database

Berikut langkah-langkah remote database di hosting dengan Navicat :

  1. Download dan install aplikasi Navicat terlebih dahulu.
  2. Login ke cPanel hosting.
  3. Cari menu Database lalu pilih Remote MySQL®.

Cara menggunakan php download remote file

4. Kemudian bisa tambahkan IP Public koneksi yang Anda gunakan, untuk cek IP Public bisa akses ke https://ipsaya.com/.

Cara menggunakan php download remote file

5. Selanjutnya, silahkan masukkan IP Address yang tampil pada https://ipsaya.com/ ke kolom Host pada menu Add Access Host di Remote MySQL®, lalu klik Add Host.

Cara menggunakan php download remote file

6. Setelah Add Host, akan muncul notifikasi IP Statis telah berhasil ditambahkan ke whitelist cPanel.

Cara menggunakan php download remote file

7. Selanjutnya buka aplikasi Navicat yang sudah diinstall pada komputer Anda, lalu klik menu Connection > MySQL.

Cara menggunakan php download remote file

8. Berikut penjelasan kolom yang perlu Anda pahami menggunakan remote database dengan aplikasi Navicat :

  • Connection Name : nama koneksi database
  • Host : nama domain atau IP hosting tempat server database
  • Port : port default 3306
  • User Name : nama username database
  • Password : password username database

9. Selanjutnya klik tombol OK. Apabila ingin lakukan test koneksi apakah sudah benar atau belum, bisa klik tombol Test Connection.

Cara menggunakan php download remote file

10. Selamat, Anda telah berhasil konfigurasi remoted database menggunakan aplikasi Navicat di layanan hosting Rumahweb Indonesia.

In this article, we will see how to download & save the file from the URL in PHP, & will also understand the different ways to implement it through the examples. There are many approaches to download a file from a URL, some of them are discussed below:

Using file_get_contents() function: The file_get_contents() function is used to read a file into a string. This function uses memory mapping techniques that are supported by the server and thus enhances the performance making it a preferred way of reading the contents of a file.

Syntax:

file_get_contents($path, $include_path, $context, 
                  $start, $max_length)

Example 1: This example illustrates the use of file_get_contents() function to read the file into a string.

PHP




<?php

  

    // Initialize a file URL to the variable

    $url

    'https://media.geeksforgeeks.org/wp-content/uploads/gfg-40.png'<?php0

<?php

    <?php3

    <?php5 <?php6<?php7<?php8$url 0

<?php

     3

     5

     7

     9 <?php8    1<?php8<?php5    4    5<?php8$url    8

    // Initialize a file URL to the variable0

// Initialize a file URL to the variable1// Initialize a file URL to the variable2 // Initialize a file URL to the variable3<?php0

    // Initialize a file URL to the variable6

    // Initialize a file URL to the variable8

    // Initialize a file URL to the variable0

// Initialize a file URL to the variable1// Initialize a file URL to the variable2     3<?php0

    // Initialize a file URL to the variable6

    7

Output:

Before running the program: 

Cara menggunakan php download remote file

php source folder

After running the program:

Cara menggunakan php download remote file

File downloaded after successful execution

Cara menggunakan php download remote file

Downloaded image file

Using PHP Curl:  The cURL stands for ‘Client for URLs’, originally with URL spelled in uppercase to make it obvious that it deals with URLs. It is pronounced as ‘see URL’. The cURL project has two products libcurl and curl.

Steps to download the file:  

  • Initialize a file URL to the variable.
  • Create cURL session.
  • Declare a variable and store the directory name where the downloaded file will save.
  • Use the basename() function to return the file basename if the file path is provided as a parameter.
  • Save the file to the given location.
  • Open the saved file location in write string mode.
  • Set the option for cURL transfer.
  • Perform cURL session and close cURL session and free all resources.
  • Close the file.

Example: This example illustrates the use of the PHP Curl to make HTTP requests in PHP, in order to download the file.

PHP




<?php

    9// Initialize a file URL to the variable

    9$url

    9'https://media.geeksforgeeks.org/wp-content/uploads/gfg-40.png'<?php0

  

    9$url9

    91 2$url 0

  

    97

    99

    9    1 <?php6    3<?php0

  

    9    7

    9    9

    9<?php5 <?php6<?php7<?php8$url 0

  

    9'https://media.geeksforgeeks.org/wp-content/uploads/gfg-40.png'9

    9<?php01 <?php6    1 <?php04<?php5<?php0

  

    9<?php09

    9<?php11 <?php6<?php13<?php8<?php01    4<?php17 0

  

    9<?php21

    9<?php231<?php25<?php11 0

    9<?php231<?php31

  

    9<?php34

    9<?php361 0

  

    9<?php41

    9<?php431 0

  

    9<?php48

    9<?php50<?php11 0

    7

Output:

Before running the program:

Cara menggunakan php download remote file

php source folder

After running the program:

Cara menggunakan php download remote file

Downloaded image file

PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples.