Home php Mediafire PHP file uploading and get link example

Mediafire PHP file uploading and get link example

by Shahriar Sagor
Mediafire PHP file uploading and get link

Today now in this post i will talk with you about Mediafire PHP file uploading and get link example. When i was working on my office new project project i need to use mediafire API for uploading the image and video, here I was saw this API is little hard to understand but it is very easy to use also. Now in this post i want to share an example of how to get link of uploaded image or video. If you are new and if you need to example for uploading then i hope it is very simple example, On that way we can solve well. Here I also see other example from google search but that was more difficult to understand and use also.

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



ini_set('display_errors', 1);


$appId = "";
$apiKey = "";
$email = "";
$password = "";


<html xmlns="http://www.w3.org/1999/xhtml" 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);


Read Also : How to convert Object into Array in PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook.


You may also like