views:

33

answers:

3

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()?

A: 

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.

UltimateBrent
I don't get what you mean by "file's header". I'm talking about HTTP request headers.
DataSurfer
Clarified a little.
UltimateBrent
+1  A: 

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
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."
UltimateBrent
Ouch. Thanks, didn't realize that. Sounds weird.
zeh
A: 

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.

Eugene