Get File Information
Upload a file
Download a file

Get file information:


You must pass your API key and the file's ID via post or get. The ID of the file is contained within the link to the file: http://www.filepup.net/files/[FILE_ID].html

Example Get:
http://www.filepup.net/api/info.php?api_key=1234567890&file_id=1234567890

Output:
Array ( [file_id] => QCRssxD12y0260423 [file_name] => myFile.rar [file_type] => application/octet-stream [file_size] => 1434112 )


Uploading Files:


The following code is just an example, you can achieve the same affect in other programming languages.

Example:
class Uploader { var $filePath; var $uploadURL; var $formFileVariableName; var $postParams = array (); function Uploader($filePath, $uploadURL, $formFileVariableName, $otherParams = false) { $this->filePath = $filePath; $this->uploadURL = $uploadURL; if(is_array($otherParams) && $otherParams != false) { foreach($otherParams as $fieldName => $fieldValue) { $this->postParams[$fieldName] = $fieldValue; } } $this->postParams[$formFileVariableName] = "@" . $filePath; } function get_furl($url) { $furl = false; $headers = get_headers($url); if(preg_match('/^HTTP\/\d\.\d\s+(301|302)/',$headers[0])) { foreach($headers as $value) { if(substr(strtolower($value), 0, 9) == "location:") { $furl = trim(substr($value, 9, strlen($value))); } } } $furl = ($furl) ? $furl : $url; return $furl; } function UploadFile() { $finalurl = $this->get_furl($this->uploadURL); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $finalurl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postParams); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $postResult = curl_exec($ch); if (curl_errno($ch)) { print curl_error($ch); print "Unable to upload file."; exit(); } curl_close($ch); return $postResult; } }

The example below will upload the file as a non-registered user.
If you want the file to appear in your FilePup account simply point to
/api/idupload.php instead of /api/upload.php that has been given in the example below:


    $upload_server = "http://www.filepup.net/api/upload.php"; // or use /api/idupload.php to upload to your account
    $upload = new Uploader('file.rar', $upload_server, 'file', array('api_key' => 'YOUR_API_KEY'));
    $result = $upload->UploadFile();

    if(preg_match("/upload_failed/", $result)){ echo "Upload failed."; }
    if(preg_match("/invalid_api/", $result)){ echo "Invalid API key."; }

    if(preg_match("/upload_success/", $result)){ echo $result; }

Output:
upload_success
http://www.filepup.net/files/123456789/myfile.rar.html
http://www.filepup.net/delete/123456789/123456789/myfile.rar.html


Downloading Files (BAAS accounts only):

FilePup's download API is under development.