UPDATED: I am developing an Air App for mobile and I have a file called "database.db" in the applicationDirectory
that is included or added via the Flash CC IDE. I am offering someone a bounty of 150 if they can help me through this issue, that is, help me with the upload script on my server as well as getting my ActionScript to upload the "database.db" file to it.
What do I hope my script will achieve?
I want to back this database up from time to time so I am hoping to upload it to a server. How would I do this?
The code below does not work and gives this error.
UPDATE: Here is the error I am getting:
TypeError: Error #1034: Type Coercion failed: cannot convert "app:/database.db" to flash.net.FileReference.
I don't believe my question is an exact duplicate as I need to upload a file and the example given does not show how the data is turned into a datatype for upload.
Do I have a server? Yes, but as of now I don't have the PHP script needed to handle this the upload, but I am at the moment trying to simple get the file from AS3 to be ready for an upload and this is what I can't do.
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequestMethod;
import flash.events.Event;
import flash.net.FileReference;
import flash.net.FileFilter;
import flash.utils.*;
import flash.filesystem.File;
public class Main extends MovieClip {
private const UPLOAD_URL: String = "http://mywebsite.com/upload.php";
private var fr: FileReference;
public function Main()
{
var dir: File = File.applicationDirectory;
dir = dir.resolvePath("database.db");
trace(dir.url); // app:/database.db
var file: FileReference = FileReference(dir.url);
var request: URLRequest = new URLRequest();
request.url = UPLOAD_URL;
fr.upload(request);
}
}
}