Uploading files through Flash iface

Hello…

I am trying to build an application that will allow users to “design” their own advertisement for a magazine. The idea is that the user loads his/her images into the Flash app, moves then around and then saves the layout.

I was HOPING that the user could load the images from their LOCAL drive into the Flash app, move stuff around, and then save the layout and images on the server. Unfortunately it looks like you can NOT load images locally from the user’s computer into Flash :frowning:

Seems like I will have to load the images first onto the server, and then load them back down into the Flash App. The files are going from local -> server -> back to local. Seems like a lot of unnecessary file movement? Any ideas?

I have found the following posts that relate to my issue, but none of them seem to be answered:

http://www.kirupaforum.com/forums/showthread.php?t=33514
http://www.kirupaforum.com/forums/showthread.php?t=35221
http://www.kirupaforum.com/forums/showthread.php?t=52202
http://www.kirupaforum.com/forums/showthread.php?t=38903

THANKS.

Looks like I found my answer. There may be a more elegant solution, but this one works for me…

You can put an HTML form in your page:


<form name="getfiles" method="post" action="#">
<input class="formobj" type="File" name="filepath" size="50" onchange="return submitpath();">
</form>

Then you can use a JavaScript function to respond to said form:


<SCRIPT LANGUAGE=JavaScript>
<!--
function submitpath(){
	// define local variable for value of form control object
  	var localpath = document.getfiles.filepath.value;
  	// use "SetVariable" method of Flash object (name=proto, id=proto)
	// setVariable(variable name, variable value)
  	document.proto.SetVariable("imagepath.text",localpath);
	// do not execute form action
	return false;
}	
//-->
</SCRIPT>

The OBJECT and EMBED HTML tags for my Flash document must identify the Flash movie. I used the name: “proto” as noted above.

Inside my Flash movie I have a textfield named: “imagepath” as noted above.

Once the textfield (imagepath) has the local path to my image, I can use the LoadMovie method and that’s it!

More information at the Macromedia site:
http://www.macromedia.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html
http://www.macromedia.com/support/flash/ts/documents/java_script_comm.htm