# File upload request

To upload a file to the server, you need to send POST data containing login, password, file variables. The response will be the id of the saved file, which you can later use in xml-requests.

## File upload request

<mark style="color:green;">`POST`</mark> `http://lk.mysmpp.ru/xml/file.php`

#### Request Body

| Name                                       | Type   | Description                                                                                       |
| ------------------------------------------ | ------ | ------------------------------------------------------------------------------------------------- |
| login<mark style="color:red;">\*</mark>    | String | Your login in the system                                                                          |
| file<mark style="color:red;">\*</mark>     | data   | File to be sent                                                                                   |
| token<mark style="color:red;">\*</mark>    | String | You can use a secret key instead of login and password. To obtain it, please contact your manager |
| password<mark style="color:red;">\*</mark> | String | Your password in the system                                                                       |

{% tabs %}
{% tab title="200: OK In the case of a valid request" %}
The **`id`** of the added file in the system will be returned
{% endtab %}

{% tab title="400: Bad Request If an error occurs" %}
-Failed to copy file

-Invalid login or password

{% endtab %}
{% endtabs %}

### File upload example

{% tabs %}
{% tab title="PHP" %}

```php
$href = "http://lk.mysmpp.ru/xml/file.php"; 
// (example: $tmpfname = "C:\Program Files\file\test.jpg";)
$tmpfname = "name";
$requist['login'] = "login";
$requist['passsword'] = "passsword";
if(PHP_VERSION_ID <  56000)
    $requist['file'] = '@' . $tmpfname;
else
    $requist['file'] = new CurlFile($tmpfname, 'image/jpg');  
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $href);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requist);
$result = curl_exec($ch);
curl_close($ch);
 
echo $result;
```

{% endtab %}
{% endtabs %}
