Mediafire PHP file uploading and get link example

By Hardik Savani | April 15, 2016 | | 2428 Viewer | Category : PHP Mediafire API

Share this post:

When i was working on my project i need to use mediafire API for uploading image and video, I did see this API is little hard to undestand but it is pretty easy to use also. In this post i want to share example how to get link of uploaded image or video. If you are new and you need to example for uploading example then it is very simple example that way you can undestand very well. I also see other example from google search but that was very difficult to undestand and use too.

So ,first you should need to download mflib.php file for Mediafire API. so if you dan't have this file then you can downlaod from here: mflib.php. Now you have to just create one file in your root directory and put bellow code:




ini_set('display_errors', 1);


$appId = "";

$apiKey = "";

$email = "";

$password = "";


<html xmlns="" xml:lang="en" lang="en">


<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />

<title>PHP - MediaFire API Library - File Uploading With Get Link</title>



<form method="post" enctype="multipart/form-data" action="">

<p>Upload a file:</p>

<label title="Choose a Local File to a MediaFire account" for="file">File:</label>

<input type="file" id="file" name="file" size="30" />

<div style="clear:left;display:block;" id="dvFile"></div>

<input type="submit" id="upload" name="upload" value="Upload" />





if (isset($_POST['upload'])) {

$mflib = new mflib($appId, $apiKey);

$mflib->email = $email;

$mflib->password = $password;

$token = $mflib->userGetSessionToken(null);

$uploadkey = $mflib->fileUpload($token, $_FILES["file"]["tmp_name"],"myfiles",$_FILES["file"]["name"]);

$fileDetails = $mflib->filePollUpload($token, $uploadkey);

$link = $mflib->fileGetLinks($fileDetails['quickkey'], "direct_download", $token);