PHP code example of jayasuryacodeingil / mega-php-client
1. Go to this page and download the library: Download jayasuryacodeingil/mega-php-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jayasuryacodeingil / mega-php-client example snippets
// Save file to current directory.
$filepath = $mega->public_file_save($ph, $key);
echo 'File saved in ' . $filepath;
// Equivalent using exported link
$filepath = $mega->public_file_save_from_link($link);
echo 'File saved in ' . $filepath;
// Get content using temporary stream
$content = $mega->public_file_download($ph, $key);
// Save file to temporary directory.
$tmp = sys_get_temp_dir();
$file = $mega->public_file_save($ph, $key, $tmp);
echo 'File saved in ' . $file;
$mega = MEGA::create_from_user($email, $password);
$files = $mega->node_list();
print_r($files);
// Get file info
$file_info = $mega->node_file_info($files['f'][5]);
print_r($file_info);
$mega = MEGA::create_from_user($email, $password);
// ...
// Get current session as a base64 string
$session = MEGA::session_save($mega);
// Store in a safe place!
db_store_session($session);