Пример #1
0
 public function uploadResume($unitid, $sessionToken, $filename, $files = null, $uploadKey = "myfiles", $customName = null)
 {
     $mimetype = "application/octet-stream";
     if (strpos($filename, ";type=") !== false) {
         $parts = explode(";type=", $filename, 2);
         $filename = $parts[0];
         if (!empty($parts[1])) {
             $mimetype = $parts[1];
         }
         //!empty($parts[1])
     }
     //strpos($filename, ";type=") !== false
     if (!file_exists($filename) || !is_readable($filename)) {
         echo "File is not exist or not readable";
         return false;
     }
     //!file_exists($filename) || !is_readable($filename)
     $filesize = filesize($filename);
     if ($filesize == 0) {
         echo "File has no content";
         return false;
     }
     //$filesize == 0
     $file = $filename;
     $filename = explode('~*', $filename);
     if ($files != null) {
         $httpOptions = array("method" => "POST", "file" => array("name" => "Filedata", "path" => $file, "type" => $mimetype), "header" => array("Referer: http://www.mediafire.com", 'x-filename: ' . $filename['1'], 'x-filesize: ' . filesize($files), 'x-filehash: ' . hash_file("sha256", $files), 'x-unit-size: ' . $filesize, 'x-unit-id: ' . $unitid, 'x-unit-hash: ' . hash_file("sha256", $file)));
     } else {
         $httpOptions = array("method" => "POST", "file" => array("name" => "Filedata", "path" => $file, "type" => $mimetype), "header" => array("Referer: http://www.mediafire.com", 'x-filename: ' . $filename['1'], 'x-filesize: ' . $filesize, 'x-filehash: ' . hash_file("sha256", $file), 'x-unit-size: ' . $filesize, 'x-unit-id: 0', 'x-unit-hash: ' . hash_file("sha256", $file)));
     }
     if (is_string($customName) && !empty($customName)) {
         $httpOptions["header"][] = "x-filename: {$customName}";
     }
     //is_string($customName) && !empty($customName)
     $query = array("session_token" => $sessionToken, "signature" => $this->signature, "response_format" => "xml");
     if ($this->dupe != NULL) {
         $query = array("session_token" => $sessionToken, "signature" => $this->signature, "action_on_duplicate" => $this->dupe, "response_format" => "xml");
     }
     //$this->dupe != NULL
     //$this->actions[] = "Uploading";
     $url = $this->apiUrl["UPLOAD_RESUME"] . "?" . http_build_query($query, "", "&");
     $mflib = new mflib();
     $data = $mflib->getContents($url, $httpOptions);
     if (!$data) {
         $upload->uploadResume($unitid, $sessionToken, $filename, $files);
         return false;
     }
     //!$data
     @unlink($filename);
     @unlink($files);
     if (!isset($data["doupload"]["key"]) || trim($data["doupload"]["key"]) == "") {
         //$this->showError("Unable to upload file - Code '" . $data["doupload"]["result"] . "'");
     }
     //!isset($data["doupload"]["key"]) || trim($data["doupload"]["key"]) == ""
     return $data["doupload"]["key"];
 }
Пример #2
0
        <form method="post" enctype="multipart/form-data" action="">
            <p>Upload a file to a MediaFire account:</p>
            <p>
            	<label title="Choose Action On Duplicates Files" for="file">Choose Action On Duplicates Files:</label>
                <input type="radio" name="dupe" value="skip">Skip File -
				<input type="radio" name="dupe" value="Replace">Replace File -
				<input type="radio" name="dupe" value="Keep">Duplicate
                <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>
                <a href="javascript:_add_more();">Add Another File</a> - 
                <input type="submit" id="upload" name="upload" value="Upload" />
            </p>
            <?php 
if (isset($_POST['upload'])) {
    $mflib = new mflib($appId, $apiKey);
    $upload = new upload($mflib);
    $upload->signature = $mflib->userGetSignature();
    $upload->dupe = $_POST['dupe'];
    $mflib->email = $email;
    $mflib->password = $password;
    //echo $mflib->dupe;
    if (count($_FILES["file"]['name']) > 0) {
        //check if any file uploaded
        $GLOBALS['msg'] = "";
        //initiate the global message
        for ($j = 0; $j < count($_FILES["file"]['name']); $j++) {
            if ($_FILES["file"]['name'] != "") {
                //print_r($_FILES["file"]['name']);
                //loop the uploaded file array
                $filen = $_FILES["file"]['name']["{$j}"];
<?php

/*
 * Required parameters
 */
$appId = "";
$apiKey = "";
$email = "";
$password = "";
/*
 * Initilize a new instance of the class
 */
include "../mflib.php";
$mflib = new mflib($appId, $apiKey);
$mflib->email = $email;
$mflib->password = $password;
/*
 * Get a Access Session Token to authenticate to the API service
 *
 * This token is valid for 10 minutes only.
 */
$sessionToken = $mflib->userGetSessionToken();
/*
 * Print the user information. Other methods should be as simple as that
 */
var_dump($mflib->userGetInfo($sessionToken));
                <label title="Choose a Local File to a MediaFire account" for="file">File:</label>
                <input type="file" id="file" name="file" size="30" />
                <input type="submit" id="upload" name="upload" value="Upload" />
            </p>
            <?php 
if (isset($_POST["upload"])) {
    /*
     * Move uploaded file to current script folder and start uploading
     */
    $uploadedFile = "./" . basename($_FILES["file"]["name"]);
    if (move_uploaded_file($_FILES["file"]["tmp_name"], $uploadedFile)) {
        /*
         * Initilize a new instance of the class
         */
        include "../mflib.php";
        $mflib = new mflib($appId, $apiKey);
        $mflib->email = $email;
        $mflib->password = $password;
        /*
         * Select a file to be uploaded. The third argurment of method fileUpload() 
         * is the quickkey of the destination folder. In this case it's omitted, which 
         * means the file will be stored in the root folder - 'My files'
         */
        $sessionToken = $mflib->userGetSessionToken();
        $uploadKey = $mflib->fileUpload($sessionToken, $uploadedFile);
    }
    /*
     * Print the upload result
     */
    if ($uploadKey) {
        var_dump($mflib->filePollUpload($sessionToken, $uploadKey));
                <label title="Choose a Local File to a MediaFire account" for="file">File:</label>
                <input type="file" id="file" name="file" size="30" />
                <input type="submit" id="upload" name="upload" value="Upload" />
            </p>
            <?php 
if (isset($_POST["upload"])) {
    /*
     * Move uploaded file to current script folder and start uploading
     */
    $uploadedFile = "./" . basename($_FILES["file"]["name"]);
    if (move_uploaded_file($_FILES["file"]["tmp_name"], $uploadedFile)) {
        /*
         * Initilize a new instance of the class
         */
        include "../mflib.php";
        $mflib = new mflib($appId, $apiKey);
        $mflib->email = $email;
        $mflib->password = $password;
        /*
         * Select a file to be uploaded. The third argurment of method fileUpload() 
         * is the quickkey of the destination folder. In this case it's omitted, which 
         * means the file will be stored in the root folder - 'My files'
         */
        $sessionToken = $mflib->userGetSessionToken();
        $uploadKey = $mflib->fileUpload($sessionToken, $uploadedFile);
    }
    /*
     * Print the upload result
     */
    if ($uploadKey) {
        /*