Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uploading files with flash

Status
Not open for further replies.

Q3Man

Programmer
Oct 22, 2001
4
US
I'm designing a form on a website and would like to allow people to upload files. Its a trivial matter with HTML, but I can't seem to find a way to do it with flash. I'd like a way to do the flash equivilant of this HTML:

<FORM METHOD=&quot;GET&quot; ACTION=&quot;/cgi-bin/submit.pl?upload=1&userid=XXX&quot; ENCTYPE=&quot;multipart/form-data&quot;>
<INPUT TYPE=&quot;FILE&quot; NAME=&quot;jpegphoto&quot;>
<INPUT TYPE=&quot;SUBMIT&quot; VALUE=&quot;Upload!&quot;>
</FORM>

Is this even possible with flash, or should I be opening a new window and do the upload in straight HTML?
 
Well, no responses so far. Does anyone know if this is possible at all, or am I just spinning my wheels?
 
Do you know how to do it w/ javascript?...if so you could always make a function and call the function via flash.

Dont yell at me if its a dumb suggestion. Regards,
Anth:cool:ny
----------------------------------------
&quot;You say [red]insanity[/red] like it's a BAD THING!&quot;
 
You need some way to send the right headers - for the
multi-part formdata - and also to browse for a file.

try it with PHP and see what happens
 
I looked into that, but decided against it for two reasons. First it is a half assed way to do things (imho) and second, it severely limits what browsers can view/use your page.
 
I mean with Flash you will have to investigate sending headers with the form submission - and then getting the path for the file into the flash movie - the rest would be a simple form. But you need a way of getting that header through.
 
Well, I've received a pair of responces from the people at Macromedia. I'll post them here for the good of everyone.

---
one of the features meant to endear flash to the security concious public is that it doesn't have the ability to make changes to any system. I'm afraid uploading involves writing a file to a system. Even though it's not on the client side, it still cannot be done. You can open the html page, as you said, to do it, or you can use fscommand and call a javascript function that is built into the page that houses the flash piece. This would keep your interface all in in Flash.

hope this is useful
daniel martin


---
There is no direct way to upload files from Flash. I've seen it done with some backend scripting, but not directly from Flash. And actually that's what's happening in the HTML above. A CGI script is being called and fed some data..

So... how could we call that same CGI from Flash? Doing a loadVariables action to &quot;/cgi-bin/submit.pl&quot; is easy, and you could set two variables in the Flash movie (upload=1 / userid=XXX) and have those appeneded to the query using GET.

But I don't know how you'd set the input types. There's no real equivalent to that in Flash...

Anyone? Urami???

Regards,

Bentley Wolfe
Senior Support Engineer, Macromedia
---
 
as was mentioned you need a browse feature to choose your file, which flash doesn't have.

I've been trying to do it by placing a file form element in a blank frame and pressing it with javascript.

The blank frame could then handle the upload with ASP / PHP and then pass back the success response and file details to flash using setVariable method.

Seems I could do this with a PC but this needs to work on a Mac too.

Seems that MAC IE can't pass back as setVariable is not supported and Mac Netscape can't press a form file element with javascript.

The hunt continues. Any Ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top