Upload files to a web site

Free BrownRecluse scripts provided by SoftByte Labs and users. To use, copy the script and paste it in the BrownRecluse script editor. Modify to your need, save and run.
Post Reply
User avatar
Support
Site Admin
Posts: 3459
Joined: Sun Oct 02, 2011 10:49 am

Upload files to a web site

Post by Support »

This script will upload a file to a web site, showing how to set the multipart/form-data

Code: Select all

Output.Clear;

FName = SelectFile('File to upload','');
if FName = Nothing then Terminate;

F = New(File);
F.Open(FName);
F.Seek(BeginningOfFile);

DecodeFileName(FName, [fn, ex], [FileName,Extension]);

Link = New(URL);

Link.Location = Input('Enter the URL to upload the file to:');
if Link.Location = Nothing then Terminate;
Link.Referer = Link.Location;

Link.AddHeader('Content-Type: multipart/form-data; boundary=---------------------------7da23915ad0a2c');

pd = '-----------------------------7da23915ad0a2c'+crlf+
     'Content-Disposition: form-data; name="file1"; filename="'+fn+ex+'"'+crlf+
		 'Content-Type: application/x-zip-compressed'+crlf+crlf+
		 F.Content+
		 crlf+crlf+'-----------------------------7da23915ad0a2c--'+crlf;

Link.Post(pd);

Output(Link.ServerText);
Your support team.
https://SoftByteLabs.com
Post Reply