/
/
API: Uploading a file to the server

API: Uploading a file to the server

To upload a file to the server via the ispmanager 6 API panel, you need to execute the following cURL request:

> curl -k -X POST "https://%PANEL_ADDRESS%/mancgi/upload" \
  -H "Cookie: ispmgrlang5=dragon:ru; ispmgrses5=%SESSION_ID% \
  -H "Referer: https://%PANEL_ADDRESS%/ispmgr" \
  -F "func=file.upload" \
  -F "out=json" \
  -F "plid=%FILE_DOWNLOAD_DIRECTORY%" \
  -F "elid=%FILE_NAME_AFTER_DOWNLOAD%" \
  -F "name=%FILE_NAME_AFTER_DOWNLOAD%" \
  -F "mgrname=ispmgr" \
  -F "type=data" \
  -F "sok=ok" \
  -F "filename=%PATH_TO_THE_DOWNLOAD_FILE%"

To get the session ID for the ispmgrses5 parameter, run the following request to the target panel by pasting it into the address bar:

https://%PANEL_ADDRESS%/ispmgr?out=xml&func=auth&username=%USER%&password=%PASSWORD%

Example

As an example, let's assume you need to upload a file.txt file located at /home/user/Documents/ from a Linux PC to a panel at 192.168.22.88:1500.

First, obtain the user's session ID on the target panel. Let's assume the file will be uploaded by the root user with the rootpasswd password:

https://192.168.22.88:1500/ispmgr?out=xml&func=auth&username=root&password=rootpasswd

After executing this request, you will receive the root user's session ID as a sequence of characters. For example:

4c2urd256a0781b5f4d73d2a0

Now you can upload the file.txt file, to a directory (for example, /var/www/www-root/data/) on the server with the panel:

> curl -k -X POST "https:///192.168.22.88:1500/mancgi/upload" \
  -H "Cookie: ispmgrlang5=dragon:ru; ispmgrses5=4c2urd256a0781b5f4d73d2a0 \
  -H "Referer: https:///192.168.22.88:1500/ispmgr" \
  -F "func=file.upload" \
  -F "out=json" \
  -F "plid=/var/www/www-root/data/" \
  -F "elid=file.txt" \
  -F "name=file.txt" \
  -F "mgrname=ispmgr" \
  -F "type=data" \
  -F "sok=ok" \
  -F "filename=/home/user/Documents/file.txt"

In this article