Jump to content

Content-Type: multipart


Recommended Posts

Hi,

A follow up from here I now trying to use the *Post_Server* script from here

in a POST response back to the script this is what i managed to receive (a POST back from a submitted form)

Accept: */*
Content-Length: 1283
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------2b466814ebaf785b

That is some sort of an array, right ?
Any one have an idea how it can be made to be received in readable format and in to an array perhaps

Thanks

Edit:  I have been explained it is done in PHP like so, where print_r($post, TRUE) is the real deal

<?php
$file = 'textfile.txt';
$post = stripslashes_deep($_REQUEST);
$post_content = print_r($post, TRUE);
$fp = fopen($file, 'w') or die('Could not open file!');
fwrite($fp, $post_content) or die('Could not write to file');
fclose($fp);
?>

 

Edited by Deye
Link to comment
Share on other sites

Just to see if im understanding ..,so this is treated as a header that comes as POST

Content-Type: multipart/form-data; boundary=------------------------2b466814ebaf785b


Then what ? , I determine that the header contains the string "boundary=--" and then make a request to the forms address at the address where its been submitted to  receive data
Still not sure what to try ..

Thanks

Link to comment
Share on other sites

When a request comes with boundary, here's what it looks like (example taken from HTML specs posted by @Kyan):

Content-Type: multipart/form-data; boundary=AaB03x

   --AaB03x
   Content-Disposition: form-data; name="submit-name"

   Larry
   --AaB03x
   Content-Disposition: form-data; name="files"; filename="file1.txt"
   Content-Type: text/plain

   ... contents of file1.txt ...
   --AaB03x--

As you can see, the boundary is used as separator between the different form inputs, such that:

  • --[boundary] is used to separate different inputs
  • --[boundary]-- is used at the end of the request

However note that it only happens when you're using `<form enctype="multipart/form-data" method="post">`. If you are using just `<form method="post">`, you will only get a URL encoded line with all the key=value pairs of form inputs at the last line of the request as I posted on the other thread (no boundaries needed). However you are only able to accept file uploads with multipart/form-data (so if you are not willing to do file uploads, I'd recommend not to use this encoding type).

My stuff

Spoiler

My UDFs  _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS ·  storage.au3 localStorage and sessionStorage for AutoIt Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path GUICtrlStaticMarquee static text scrolling Random stuff Super Mario beep sound your ears will hurt

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...