Adobe reference specifically points this out as a limitation.
Here's the note in the file.upload functionality in adobe reference.
Note: If your server requires user authentication, only SWF files running in a browser — that is, using the browser plug-in or ActiveX control — can provide a dialog box to prompt the user for a username and password for authentication, and only for downloads. For uploads using the plug-in or ActiveX control, or for uploads and downloads using the stand-alone or external player, the file transfer fails.
click here for the full reference page for File
Has anyone been able to work around this limitation. One thought I had was to use the native support in AIR for Javascript and see that works. Anyone tried that? Anyone have other ideas?
I've also tried the solution proposed here and it didn't work. According to the questioner in the forum it didn't seem to work for him either. Probably hitting the issue/limitation mentioned above.
I understand how to include basic authentication on a URLRequest and that works fine for me if I'm posting key/value pairs. But when I attempt to upload a file it does not work. It just sits there and does not fire any of the file.upload events. No errors no progress. Any help is much appreciated.
Here's my sample code:
var sendVars:URLVariables = new URLVariables();
sendVars.prop1 = "filename" ;
var urlRequest:URLRequest = new URLRequest();
urlRequest.method = URLRequestMethod.POST ;
urlRequest.data = sendVars ;
var encoder:Base64Encoder = new Base64Encoder();
encoder.encode("user:pass");
var credsHeader:URLRequestHeader = new URLRequestHeader("Authorization", "Basic " + encoder.toString());
urlRequest.requestHeaders.push(credsHeader);
file = new File(url);
file.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA , file_UploadCompleteDataHandler );
file.addEventListener( Event.OPEN, fileOpenHandler);
file.addEventListener(ProgressEvent.PROGRESS, fileProgressHandler);
file.addEventListener(Event.COMPLETE, file_CompleteHandler);
file.addEventListener(IOErrorEvent.IO_ERROR, file_IOErrorHandler);
file.addEventListener(HTTPStatusEvent.HTTP_STATUS , file_HTTPStatusHandler);
file.addEventListener(SecurityErrorEvent.SECURITY_ERROR, file_SecurityErrorHandler);
try {
// Start the file upload
file.upload(urlRequest, "primaryFile", false);
}
catch (error:Error) {
trace( "Unable to upload file." + file.name);
}