Something like this?

        private function dropped(ev:DragEvent):void{  
                ev.preventDefault();
                var fileList:FileList = ev.dataTransfer.files;
                dispatchEvent(new ValueEvent("filesAvailable",fileList));
        }

The code from FileLoader is relevant for getting the binary content of a file:

                public function load():void
                {
                        COMPILE::SWF
                        {
                                
fileModel.fileReference.addEventListener(Event.COMPLETE, fileLoadHandler);
                                fileModel.fileReference.load();
                        }
                        COMPILE::JS 
                        {
                                var reader:FileReader = new FileReader();
                                goog.events.listen(reader, 'load', 
fileLoadHandler);
                                
reader.readAsArrayBuffer(fileModel.fileReference);
                        }
                }
                
                COMPILE::SWF 
                protected function 
fileLoadHandler(event:flash.events.Event):void
                {
                        
fileModel.fileReference.removeEventListener(Event.COMPLETE, fileLoadHandler);
                        fileModel.fileContent = new 
BinaryData(fileModel.fileReference.data);
                }


> On Jul 11, 2023, at 7:26 PM, cont...@cristallium.com wrote:
> 
> Hi All,
> 
> I struggle with drag and drop and upload file to a remote server.
> 
> I can upload file using FileReference (_fr), this is working fine :
> 
>            private function ev_SelectedFile(e:Event):void {
>                var url:URLRequest = new 
> URLRequest("http://myserver.com/upload_file.php";)
>                url.method = "POST";
>                trace ("selected1:" + (e.currentTarget as 
> FileReference).fileReference.name);
>                trace ("selected2:" + (e.currentTarget as 
> FileReference).fileReference.size);                 _fr.upload(url);
>            }
> 
> Now, instead to be _fr.browse(), I want the source of upload to be a drag and 
> drop file.
> I have an event working using jewel DropZone when I drop a file, but how to 
> setup FileReference ? Here is my buggy code :
> 
> private function ev_dropped(e:DroppedEvent):void {
> 
>                trace ("dropped");
>                //_fr.fileReference = new File((e.data[0] as 
> DroppedModel).fileData.array,"test.mp3");
>                _fr.fileContent = (e.data[0] as DroppedModel).fileData;
>                var url:URLRequest = new 
> URLRequest("http://myserver.com/upload_file.php";)
>                url.method = "POST";
>                _fr.upload(url),
> }
> 
> Thank in advance for help
> Regards
> Fred

Reply via email to