Gabriel
Gabriel

Reputation: 1751

How do I set a header on the request generated by FileReference?

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

Upvotes: 2

Views: 2156

Answers (4)

Caius Miron
Caius Miron

Reputation: 31

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

Upvotes: 0

Eugene
Eugene

Reputation: 2216

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.

Upvotes: 0

Brent
Brent

Reputation: 23702

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.

Upvotes: 1

zeh
zeh

Reputation: 10659

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

Upvotes: 1

Related Questions