Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • Last Modified:

Image Upload HELP - Please!


I am having a problem with uploading an image via flash and am hoping someone could lend their flash expertise.

I am developing a TEXT to HTML text editor and would like to have the ability to upload images as well. I am able to 'browse' and locate files, however I cannot attatch them and have the path display on the dynamic input text.

What I would like to have happen is this.

1) Click on the 'image' icon.
2) Dialog box is displayed with a 'browse' button
3) User selects desired file.
4) File is presented in dynamic text area
5) User clicks 'Done' and the text is carried over into the 'Editor' screen.

I located a tutorial which works by itself, however when I attempt to incorporate it into my image upload movie, it doesn't work... Here is the tutorial file.

If anyone out there could assist me with this I would be most appreciative.

P.S. - I am attathing the files which I am using for reference in hopes someone can look at and tell me what I am missng.

Thank you in advance!

You can access the fla, swf and html files here:

1 Solution
hmmm ... i know what u are trying to do ...  i have done similar thing which allow user to upload their files etc thru flash (at leastlooks like it) ... using the file field in html.

but this thing does work with MAC, NN etc ...
anyway, i haven't open u code yet to see what exactly happen... just a guess ...

let me check in a while
I tried it, and your example actually works as given with me, IE 6.1, WinXP Pro, so what are you using?
this is what is wrong ...

setInterval("document.all['movie'].SetVariable('filename', filename);", 100);

<OBJECT ......
 WIDTH="100%" HEIGHT="100%" id="my_editor2" ALIGN="">

in the javascript u have the movie name call
document.all['movie'] ....

and the object tag for IE u have id="my_editor2"

that's why u can't get the variables in ur swf ...

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

just a note ...

<object> tag is for IE
<embed tag is for NN

when u do a document.all['ID NAME HERE']
it is the id from the object tag which the browser look for not the <param> tag

just a comment on this subject...

Do you really need to return the long path to the file in your document?  I have developed this type of application as well and chose not to display the path at all...  

It is quite ugly to see the path in a text box anyway, and the user will not care one bit if they can see the path.  I think this issue comes up too often, and developers need to ask why they are every doing it.

Unless it is imparitive to make the application work, which I doubt, you should just simplify everything.

just have button that says "upload image" in the first frame, and have it take them to the next frame after the javascript.  The second frame should have a sutton that says "submit".  It simplifies the process, and gets rid of any user confusion, and the ugly long path to the file...

just my opinion on the subject... take it for what it is worth.

sukimasterAuthor Commented:
Thank you all for your responses. However, I still cannot get this to work. It's been a while since I've used flash and am basically piecing together this project and learning quite alot in the process.

After changing the following from

setInterval("document.all['movie'].SetVariable('filename', filename)", 100);


setInterval("document.all['my_editor2'].SetVariable('filename', filename)", 100);

it is still not uploading or showing the path.

rascalpants  -  In regards to your most recent question, I agree that it's not imperitive that it be shown in the text area. I would like to see you example or if you wouldn't mind, possibly incorporating it into my code. It's completely open source...

It is necessary however to, once the file is selected in the 'browse' path, to pass it into the 'Editor' screen. This way the user can preview it then if he or she decides they like it I'll export it and the file upload is executed. Otherwise the file is just referenced and displayed by using the path provided on their desktop.

If anyone could incorporate this function and then give it back to me I'd certainly appreciate it. I can then see how exactly you did it. Been battling with this problem for 4 days and can't take it anymore!! :)

Thanks again for all of your questions and assistance.


oh .. sorry ...
i forgot ..

i changed one more thing ...
the text box in ur movie
it should set the variable to /:filename

since u are sending the filename to the swf (root)

cheers :)
sukimasterAuthor Commented:
I'd also consider even a simple HTML popup which allows the user to specify the file there and then when complete, the variable is transfered to the 'Editor' screen.

Again, these were issues I was unable to accomplish so if any knows how I could update my fla file to include the HTML window var I would be so happy! :)

sukimasterAuthor Commented:
henryww - could you email me the adjustments you made? webman@pumpkincutter.com

I'll then give you the accepted answer as I couldn't get it to work using the references you specified.

it works fine, i have change ur fla, so to point textbox to /:filename and make multiline off ...

i agree with rp and that's how i did it in my project too ...

here's the code what u can do to chop the filename off ... i hope i am giving u an "elegant" solution !!!

    function check()
      setInterval("filename=document.all['ieinput'].value", 100);
      setInterval("chopFilename();", 100);
    if (ie4) setTimeout("check()", 500);
     function chopFilename() {
          if (filename == "") return true;
          sidx = filename.lastIndexOf("\\");
          filename = filename.substring(sidx+1,filename.length);
          document.all['movie'].SetVariable('filename', filename);

so u call a function in call chopFilename if there is a filename and return only the filename with no path.

the file is on it's way ...


in fact i did a similar project which allows ppl to upload file and ... this similar method, it doesn't work with all browsers all platform ... not for macs ... so i decide to keep the nicely masked method for IE & PC and have a popup for mac ... that's how it ended up :)

sukimasterAuthor Commented:
This works! Thank you all! I only have a problem with the z-index and preview option now but I think that henryww and rp are taking a look at it.

I've updated the zip file with the current status for your review and suggestions/input.

Thanks again guys!~! :)

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now