PDA

View Full Version : File upload, plz help



patrickgates
January 3rd, 2009, 04:26 PM
I am working on a script that would allow people to import files from their hard drive into this swf file and add effects to their photos, then download the files

I'm having trouble allowing people to import images into the flash file, without uploading them to the server

I have experience in php also, if server side programming is necessary


Thank you so much
-Patrick Gates

Krilnon
January 3rd, 2009, 05:27 PM
You can load a file directly into Flash Player from the user's hard drive with Flash Player 10 using a FileReference instance's load method.

patrickgates
January 3rd, 2009, 10:14 PM
I can't seem to figure it out


Can anyone give me the exact code

dail
January 4th, 2009, 01:36 AM
From Programming ActionScript 3 - Page 614



package
{
import flash.display.Sprite;
import flash.events.*;
import flash.net.FileFilter;
import flash.net.FileReference;
import flash.net.URLRequest;
import flash.utils.ByteArray;

public class FileReferenceExample1 extends Sprite
{
private var fileRef:FileReference;
public function FileReferenceExample1()
{
fileRef = new FileReference();
fileRef.addEventListener(Event.SELECT, onFileSelected);
fileRef.addEventListener(Event.CANCEL, onCancel);
fileRef.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
fileRef.addEventListener(SecurityErrorEvent.SECURI TY_ERROR,
onSecurityError);
var textTypeFilter:FileFilter = new FileFilter("Text Files (*.txt, *.rtf)",
"*.txt;*.rtf");
fileRef.browse([textTypeFilter]);
}
public function onFileSelected(evt:Event):void
{
fileRef.addEventListener(ProgressEvent.PROGRESS, onProgress);
fileRef.addEventListener(Event.COMPLETE, onComplete);
fileRef.load();
}

public function onProgress(evt:ProgressEvent):void
{
trace("Loaded " + evt.bytesLoaded + " of " + evt.bytesTotal + " bytes.");
}

public function onComplete(evt:Event):void
{
trace("File was successfully loaded.");
trace(fileRef.data);
}
public function onCancel(evt:Event):void
{
trace("The browse request was canceled by the user.");
}

public function onSaveCancel(evt:Event):void
{
trace("The save request was canceled by the user.");
}

public function onIOError(evt:IOErrorEvent):void
{
trace("There was an IO Error.");
}
public function onSecurityError(evt:Event):void
{
trace("There was a security error.");
}
}
}