Welcome, Guest. Please login or register.
Did you miss your activation email?
05/23/12, 01:53
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  The Library
| |-+  Technical Reference Area (Moderators: Flash-db, Musicman, BurtonRider1983, vesa kortelainen, Ronald Wernecke, Jorge Solis)
| | |-+  Local File Browsing with Flash and JavaScript
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 Print
Author Topic: Local File Browsing with Flash and JavaScript  (Read 14896 times)
mrflash
Server what's that
*
Posts: 1



View Profile WWW
« on: 01/22/04, 00:08 »

You'd think that it would be an easy thing to do since choosing a file on the local system and uploading it to the server is perspicaciously accomplished in html with a form containing <input type='file'> that posts to a php/asp/jsp script, which finally copies the file to the sever. I am not going to cover the later in this tutorial, if you need help with file copy to the server, send a note, I can tell you how using php.

At http://www.yamago.net/components/ you can download a component (thx jorge) that will allow you to browse the local file system via your web browser's file locator pop-up window. Yamago accomplishes this feat with a quite complex script that hovers a hidden div that contains a <input type='file'> over the flash button labeled 'browse'. It is really neat but extraneously complex.

Here's another approach, tested only in IE6 and NS7.1 (mozzilla 1.3), I believe that mozzilla 1.2 will not allow variable passing to flash via swLiveConnect, I digress, anyway:

1) In the flash movie, make a buttton with:

   on(release){
     fscommand("","");
     //fscommand needs to have two parameters,
     //you can leave them empty here though
   }

   And create an input or dynamic field and give it a value for var, such as 'flashVar'

Make sure that your publish settings are set to 'Flash with fscommand', publish the movie and use the code that flash generates to allow the fscommand call to work with IE as well as Netscape.

2) Let's say you published the movie with the file name myMovie, there will be a function generated:

   function myMoive_DoFSCommand(command, args) {
      var fstestObj = InternetExplorer ? fstest : document.fstest;
     //
     b = window.open('browse.html','browse','height=55,width=300,left=200,top=200');
     b.focus();
     //add these lines of code to the script
     //
     //
   }
Add this function to the script:

   function setFlashVar(value){
     window.document.myMovie.SetVariable("flashVar", value);
   }

3) Create an html file called browse.html and include the following within the body tag:

   <SCRIPT LANGUAGE=JavaScript>
   <!--
   function setFlash(value){
     window.opener.setFlashValue(value);
     window.close();
   }
   </script>
   <input type="file" size="30" onChange="setFlash(this.value)">

That's it! Hopes it works out for you, enjoy! You can see an example at:
http://www.hallwaymedia.com/file-browse-flash-javascript/
« Last Edit: 01/22/04, 19:46 by mrflash » Logged
memepool
Server what's that
*
Posts: 4



View Profile WWW Email
« Reply #1 on: 06/14/04, 13:05 »

Hi can you elucidate further on the scripting for getting the image from flash into a directory on the server? I am using
copy ($_FILES['image']['tmp_name'], "files/".$_FILES['image']['name']);
but cannot seem to get it to work with flash although it works fine from a standard html form.
Logged
Musicman
Administrator
Systems Administrator
*****
Posts: 2685



View Profile WWW Email
« Reply #2 on: 06/14/04, 17:34 »

Hi  mrflash,

maybe this stuff is working on windows, but the browse button does nothing when tested in mozilla1.4 on Linux - I believe replacing the fscommand things with geturl javascript could help

qmemepool: once flash knows about the file, it can do nothing with it other than open (loadmovie) - flash does not have a mechnism to upload files

Musicman
Logged
memepool
Server what's that
*
Posts: 4



View Profile WWW Email
« Reply #3 on: 06/15/04, 04:39 »

yes but flash can output a string containing the path to the file and then php  should then be able to upload the file as it does via a standard html form. However for some reason I can't get this to work with the script above.

Logged
Musicman
Administrator
Systems Administrator
*****
Posts: 2685



View Profile WWW Email
« Reply #4 on: 06/15/04, 06:24 »

Hi,

file upload means that the browser is pushing the data from the server ... not that the server is pulling them from the client.
If there were a method for "something" to give a string describing what file should be pulled, you would get hundreds of websites attempting to pull up secret files in known places (such as homebanking secrets, windows password list)

Musicman
Logged
memepool
Server what's that
*
Posts: 4



View Profile WWW Email
« Reply #5 on: 06/15/04, 10:48 »

Hi all I want to do is use a flash form to upload an image instead of an html form? the php manual http://uk2.php.net/manual/en/features.file-upload.php example works perfectly fine with html forms but not with flash for some reason.
Logged
vesa kortelainen
Administrator
Systems Administrator
*****
Posts: 3450


View Profile
« Reply #6 on: 06/15/04, 11:20 »

why you wanna use flash for that Huh

Logged
memepool
Server what's that
*
Posts: 4



View Profile WWW Email
« Reply #7 on: 06/15/04, 11:24 »

because the site is already been built !
Logged
vesa kortelainen
Administrator
Systems Administrator
*****
Posts: 3450


View Profile
« Reply #8 on: 06/15/04, 12:30 »

aha.
Logged
Pluda
Senior Programmer
****
Posts: 270


View Profile
« Reply #9 on: 07/22/04, 11:09 »

Hi there,

I'm running unther MacOs X, and I need to use this file browsing system, but the fscommands doesn't work here (not even in Internet Explorer).

Is it possible to use

on(release){
   getURL("javascript:the script?");
}

I don't know any of javascript, so I'm asking if it is possible to you to make this or to point me in the righ way to make this work.

Many thanks!

Pluda
Logged
Musicman
Administrator
Systems Administrator
*****
Posts: 2685



View Profile WWW Email
« Reply #10 on: 07/22/04, 11:16 »

Hi,

have a look at http://wolfgang.remsnet.de/gallery/admin.php (user image, pass upload)
This will popup a html form for the upload from the flash form - this is probably as close as you can get without being tied to one specifice browser / OS

Musicman
« Last Edit: 07/22/04, 11:47 by vesa kortelainen » Logged
Pluda
Senior Programmer
****
Posts: 270


View Profile
« Reply #11 on: 07/22/04, 11:23 »

Hi there,

Thanks for replying!

The link you post isn't working...

<Server not found>

Pluda
Logged
vesa kortelainen
Administrator
Systems Administrator
*****
Posts: 3450


View Profile
« Reply #12 on: 07/22/04, 11:47 »

now the link is fiXed.
Logged
Pluda
Senior Programmer
****
Posts: 270


View Profile
« Reply #13 on: 07/22/04, 12:55 »

Hello,

Yes, thats what I need.
Is it much if I ask you the source?

Many thanks!  Grin
Logged
Musicman
Administrator
Systems Administrator
*****
Posts: 2685



View Profile WWW Email
« Reply #14 on: 07/23/04, 00:12 »

Hi,

Just PM me with your email.
Just to tell you in advance; there is no flash source, since this has been done with ming. You will need to read through the explanatory text I wrote for this, and copy the scripts from the php/ming file to your fla

Musicman
Logged
Pages: [1] 2 Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything