2

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/FileReference.html

How do I add my own request header to the POST requests generated by FileReference.upload()?

Gabriel
  • 1,468
  • 2
  • 13
  • 33

4 Answers4

1

In short, no.

From the docs:

The requestHeaders property of the URLRequest object is ignored; custom HTTP request headers are not supported in uploads or downloads.

EDIT: just fixed some specifics.

Brent
  • 21,918
  • 10
  • 42
  • 49
1

Have you tried created an URLRequest with its own URLRequestHeader entries?

var request:URLRequest = new URLRequest("http://www.example.com/post.php");
request.method = URLRequestMethod.POST;

var header:URLRequestHeader = new URLRequestHeader("pragma", "no-cache");
request.requestHeaders.push(header);

fileRef.upload(request); 
zeh
  • 8,471
  • 3
  • 32
  • 50
  • 5
    Fantastic idea, but it doesn't work. :( from docs: "The requestHeaders property of the URLRequest object is ignored; custom HTTP request headers are not supported in uploads or downloads." – Brent Sep 16 '10 at 20:54
  • Ouch. Thanks, didn't realize that. Sounds weird. – zeh Sep 16 '10 at 23:07
0

You can UrlRequest as before but you use a helper class to send the content of the file. Here is the answer:

https://stackoverflow.com/a/12933681/1753025

Community
  • 1
  • 1
0

Just had a same problem, use file upload via URLLoader, and use zehs solution to setup headers.

Just put your file inside of request.data, and setup method to POST.

Community
  • 1
  • 1
Eugene
  • 2,226
  • 1
  • 13
  • 15