Mediafire PHP file uploading and get link example

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


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:

index.php

<?php


error_reporting(E_ALL);

ini_set('display_errors', 1);


require_once("../mflib.php");


$appId = "";

$apiKey = "";

$email = "";

$password = "";


?>


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

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

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

</head>

<body>

<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" />

</form>

</body>

</html>


<?php


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);


print_r($link);

}


?>



Do you want to expert php developer or developer team for your projects ?
Contact US