Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does WebKitFormBoundary mean?

I'm doing a file upload using https://github.com/danialfarid/ng-file-upload but I don't understand whether I'm actually sending the file or not. The payload just says:

------WebKitFormBoundaryaym16ehT29q60rUx
Content-Disposition: form-data; name="file"; filename="webfonts.zip"
Content-Type: application/zip


------WebKitFormBoundaryaym16ehT29q60rUx--

I don't understand what this means? It sort of looks like its being uploaded but the POST comes back instantly and I expected to see some sort of file stream. Whats going on, am I sending the file or not?

like image 969
lorless Avatar asked Dec 16 '16 16:12

lorless


People also ask

What is request header boundary?

The boundary is included to separate name/value pair in the multipart/form-data . The boundary parameter acts like a marker for each pair of name and value in the multipart/form-data. The boundary parameter is automatically added to the Content-Type in the http (Hyper Text Transfer Protocol) request header.

What is a multipart form data?

Multipart form data: The ENCTYPE attribute of <form> tag specifies the method of encoding for the form data. It is one of the two ways of encoding the HTML form. It is specifically used when file uploading is required in HTML form. It sends the form data to server in multiple parts because of large size of file.

What is boundary in multipart request?

A boundary is just the 'key' to separate the multiple "parts" of a multipart payload. Normally something like '&' is enough to separate the variables but you need something more unique to separate the payloads within the payload.


2 Answers

Each item in a multipart message is separated by a boundary marker. Webkit based browsers put "WebKitFormBoundary" in the name of that boundary.

The Network tab of developer tools do not show file data in a multipart message report: They can be too big.

Use a tool like Charles Proxy to watch the request instead if you want to monitor exactly what is in there.

like image 121
Quentin Avatar answered Oct 13 '22 09:10

Quentin


That is the payload of the temporary image or document in post method. You can access the above code using php.

 <?php

  print_r($_FILES); // to print the file type params
  $target_dir = "/var/www/html/me_docs/";
  $date = date_create();
  $timestamp = date_timestamp_get($date);

  $filename = pathinfo($_FILES["filepond"]["name"],PATHINFO_FILENAME);
  $extension = pathinfo($_FILES["filepond"]["name"],PATHINFO_EXTENSION);
  $fullname = $filename.'_'.$timestamp.'.'.$extension; 

  $target_file_name = $target_dir.$fullname;

  if(move_uploaded_file($_FILES["filepond"]["tmp_name"], $target_file_name))
  {     
    echo "moving file success";
  }
  else
  {
    echo "failed moving file";
  }

I hope it is useful for someone, Thank you.

like image 38
Venkatesh Somu Avatar answered Oct 13 '22 11:10

Venkatesh Somu