> For the complete documentation index, see [llms.txt](https://ivalexev.gitbook.io/rednote/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ivalexev.gitbook.io/rednote/utility/transferring-file/code.md).

# Code

## Download

### Python2

<pre class="language-bash" data-overflow="wrap"><code class="lang-bash"><strong>python2.7 -c 'import urllib;urllib.urlretrieve ("&#x3C;URL_FILE>", "&#x3C;NEW_NAME>")'
</strong></code></pre>

### Python3

{% code overflow="wrap" %}

```bash
python3 -c 'import urllib.request;urllib.request.urlretrieve("<URL_FILE>", "<NEW_NAME>")'
```

{% endcode %}

### PHP

{% code overflow="wrap" %}

```bash
php -r '$file = file_get_contents("<URL_FILE>"); file_put_contents("<NEW_NAME>",$file);'
```

{% endcode %}

### Ruby

{% code overflow="wrap" %}

```bash
ruby -e 'require "net/http"; File.write("<NEW_NAME>", Net::HTTP.get(URI.parse("<URL_FILE>")))'
```

{% endcode %}

### Perl

{% code overflow="wrap" %}

```bash
perl -e 'use LWP::Simple; getstore("<URL_FILE>", "<NEW_NAME>");'
```

{% endcode %}

### JavaScript

{% code title="download.js" overflow="wrap" %}

```javascript
var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1"); 
WinHttpReq.Open("GET", WScript.Arguments(0), /*async=*/false); 
WinHttpReq.Send(); 
BinStream = new ActiveXObject("ADODB.Stream"); 
BinStream.Type = 1; 
BinStream.Open(); 
BinStream.Write(WinHttpReq.ResponseBody); 
BinStream.SaveToFile(WScript.Arguments(1));
```

{% endcode %}

{% code overflow="wrap" %}

```bash
cscript.exe /nologo download.js <URL_FILE> <NEW_NAME>
```

{% endcode %}

### VBScript

{% code title="download.vbs" overflow="wrap" %}

```visual-basic
dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP") 
dim bStrm: Set bStrm = createobject("Adodb.Stream") 
xHttp.Open "GET", WScript.Arguments.Item(0), False 
xHttp.Send 

with bStrm
    .type = 1
    .open
    .write xHttp.responseBody
    .savetofile WScript.Arguments.Item(1), 2 
end with
```

{% endcode %}

{% code overflow="wrap" %}

```bash
cscript.exe /nologo download.vbs <URL_FILE> <NEW_NAME>
```

{% endcode %}

## Upload

### Python3

Set [Server Python3 with Upload Option](/rednote/utility/server.md#python) (and self-signed certificate).

{% code overflow="wrap" %}

```bash
python3 -c 'import requests;requests.post("http://<IP>:<PORT>/<DIR>",files={"files":open("<FILE>","rb")})'
```

{% endcode %}

### Etc.

It is possible with all the other languages in the download section but also others.
