I got to manage Drag&Drop of files from Desktop to my Air application. If I drag images I can show them without problems. Now I want to upload them to a webspace. I found some code which seems to work, but all examples don't consider authentication, but I think I solved this problem too. The response I get back from the webserver: "Not an image or corrupt file."
Here is my code, I hope somebody has an idea to fix it.
public function onDrop(event:NativeDragEvent):void
NativeDragManager.dropAction = NativeDragActions.COPY;
var dropfiles:Array = event.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
for each (var file:File in dropfiles)
if(file.extension == "jpg")
var r:URLRequest = new URLRequest("http://localhost/...");
var encoder:Base64Encoder = new Base64Encoder();
var header:URLRequestHeader = new URLRequestHeader("Authorization", "Basic " + encoder.toString());
r.method = "POST";
r.authenticate = true;
r.contentType = "multipart/form-data";
I got it myself:
The upload method requiers another argument: