views:

23

answers:

1

I have some field in form, lets say:

 <FORM action="http://server.com/cgi/handle"
       enctype="multipart/form-data"
       method="post">
   <P>
   What is your name? <INPUT type="text" name="submit-name"><BR>
   What files are you sending? <INPUT type="file" name="files"><BR>
   <INPUT type="submit" value="Send"> <INPUT type="reset">
 </FORM>

and on submission of this form is XMLHTTPrequest generated, for example:

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--

and I want to change this request, I need to change the name and content of the file which is send. Could it be done? Is it not security issue?

A: 

I'm not sure I grasp the situation but I think you mean a normal POST request, not a XMLHTTPrequest which is specific to JavaScript (Ajax requests are based on this method).

If you are asking how to modify the request the browser sends to the server when using multipart/form-data then I am pretty sure the answer is: You can't. This is a matter completely beyond the site's control.

I also strongly doubt there is a JavaScript based way of doing this because you are using a file upload. The contents of an uploaded file are not available to the web page for security reasons, so you will have no chance of encoding that file yourself and making a raw request using XMLHTTPRequest or any other client-side method.

Pekka