sendspace API (1.2)

> Upload New File

Developer Guide

The sendspace Application Programming Interface (API) allows you to embed sendspace services in your applications, programs, or scripts, regardless of platform and programming language.
All communication with the sendspace API (1.2) assumes a UTF-8 encoding.

< Return to Method List

Method: upload.getInfo


Obtains the information needed to perform an upload.

Name Mandatory Description
session_key Yes Received from auth.login
speed_limit No Upload speed limit in kilobytes, 0 for unlimited

URL to upload the file to, progress_url for real-time progress information, max_file_size for max size current user can upload, upload_identifier & extra_info to be passed with the upload form


<result method="upload.getInfo" status="ok">
    <upload url="" progress_url="" max_file_size="" upload_identifier="" extra_info="" />
Usage Example
Possible Errors
Code Name Description
6 API_ERROR_SESSION_BAD Session expired or not found
19 API_ERROR_PRO_EXPIRED Pro user, account expired
20 API_ERROR_PRO_DISKSPACE_LIMIT Pro user, reached disk space limit
upload method

<form method="post" action="[url value received in response]" enctype="multipart/form-data">
    <!-- MUST FIELDS -->
    <input type="hidden" name="MAX_FILE_SIZE" value="[max_file_size value received in response]">
    <input type="hidden" name="UPLOAD_IDENTIFIER" value="[upload_identifier value received in response]">
    <input type="hidden" name="extra_info" value="[extra_info value received in response]">
    <input type="file" name="userfile">

    <!-- OPTIONAL FIELDS --->
    <input type="text" name="description">
    <input type="text" name="password">
    <input type="text" name="folder_id">
    <input type="text" name="recipient_email">  <!-- an email (or emails separated with ,) of recipient/s to receive information about the upload -->
    <input type="text" name="recipient_message">  <!-- a message to include in email to recipient/s -->
    <input type="checkbox" name="notify_uploader" value="1">  <!-- 0/1 - should the uploader be notified? -->
    <input type="hidden" name="redirect_url">  <!-- page to redirect after upload will be attached upload_status=ok/fail&file_id=XXXX -->
Different file input name
In case an application is used that hard codes the upload input field (such as Adobe Flash), it is possible to send this field name with the value of "userfile". The code will then know to read from that input, instead of "userfile".
When Upload Ends
If redirect_url was given, it will redirect to the URL, also adding two extra URL params to it:
* upload_status: ok/fail
* file_id: file_id (can be used in the API for later)
If no redirect_url is given, a page with the following text will be sent:


Progress Bar
Reading from progress_url will give the an XML output similar to this:

    <speed>50</speed> <!-- in kbps -->
    <uploaded_bytes>1000</uploaded_bytes> <!-- in bytes -->
    <total_size>50000</total_size> <!-- in bytes -->
    <meter>0-100</meter> <!-- percentage of upload done -->

Because the xHTTPRequest JavaScript call, for security reasons, is unable to issue requests to hosts other than the host the page originated from, you need to make use of a simple proxy to read the progress information. For example:

header("Content-type: text/xml");
echo file_get_contents($_REQUEST['url']);

Multiple Uploads
Multiple upload is supported by adding userfileN & descriptionN fields to the form where N is a number from 2 to 100.

* Use "userfile" & "description" without the number "1" for the first file.

Example for uploading 3 files:

<input type="file" name="userfile">
<input type="text" name="description">
<input type="file" name="userfile2">
<input type="text" name="description2">
<input type="file" name="userfile3">
<input type="text" name="description3">