[HTML5] How can upload file?

I want to allow user to upload image and for that reason I’m using FileReference class and his method browse() , but nothing happend.

Only in browser I saw the following message:
[openfl.net.FileReference] WARNING: upload is not implemented

How can upload image using OpenFL ( the target is HTML5) ?

Thank you.

You are using an old version of openfl by any chance?

I implemented uploading files in html5 a couple of months ago.

You can see a (hastily coded) example on how to use it: https://github.com/miltoncandelero/yajg/blob/master/Source/Glitcher.hx (the fr variable is the FileReference object)

1 Like

Filereference load() method works i.e loading image as bytearray.
My goal was to using upload() i.e. send image directly to php file , but this is not implemented.
There is way to do it, using load() and after that , this AS3 implementation https://gist.github.com/zhouji/4303867
Maybe something like this could be implemented in OpenFL.

Thank you for your help @ miltoncandelero

Sorry this is suuuuuper late but since you can get the byte array, can’t you just xhr POST it to a php rest api?

Well, that was the other solution - to use Base64 to encrypt data and send it via POST .
But at the moment I have flash and html5 version using by clients, so my wish was not to change php file ( i.e.with adding additional logic ). Also upload from html form is not straight POST query , it should sent form data - Filedata , boundary , linebreak) as it’s implemented in upload.as file/
In Flash have upload function, so my goal was to use same functionality.

Yeah this would be great if someone implemented it properly