# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apidocs.webcom.mobi/en/sposoby-vzaimodeistviya-s-a2p-platformoi/xml-specification/file-upload-request.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
