PDA

View Full Version : Allow users to browse local harddrive


TUF
03-24-2006, 04:55 PM
OK, so I have an input text box which will contain the address of a chosen file on the user's hard drive.

However, I don't want them to have to manually type in the file's address, e.g. "C:/Documents and Settings/......./something.txt".

I want them to be able to browse for files like you do in any other application when you are opening a file.. or on the web when you're uploading a file... and then be able to transfer the address of the file into the input text box after the OK button in file explorer is clicked.

So, how do I do this?

Btw I wouldn't mind creating my own file browsing interface if that has to be done. I would PREFER to just make it open the windows interface of browsing for files, file explorer.

Xeef
03-24-2006, 05:32 PM
whit flahs alone you CAN'T !

in thml you use something like :


Choose a file to upload: <input id="uploadedfile" name="uploadedfile" type="file" onChange="alert(document.getElementById('uploadedfile').valu e)" /><br />


long time didn't made anything whit HTML so no sure about the hole thing

you some how need to triger this action from flash (so the browser window is popingup)
and then on "onChange" submit the value to flash truh flashvars

in front if some body wana sugest F8 filereference
there is no way to get the Path out of it ! just the file name !
eg :
C:bla/mytext.txt --> mytext.txt
E:somethingelse/mytext.txt --> mytext.txt

mrand01
03-24-2006, 06:57 PM
Like Xeef said, you can do it using hacks in javascript and html, and passing the values to flash...but its pretty tough, I've done it before. The easier way to do it is to build the flash application into a C# application using the Flash.ocx in C#. Make your swf the source document, then pass the values back and forth with C#. If you dont know C# (or VB6 or any .NET language...or anything else), try Zinc (www.multidmedia.com). Their software makes stuff like this easy, but its not cheap.

Xeef
03-24-2006, 09:02 PM
The easier way to do it is to build the flash application into a C# application

???

this is definetly fare more complicated then to use javascript
in adition you will have a "projector/EXE" so this you can't use for a WEB SWF

mordocai
03-25-2006, 10:40 PM
Those who say you cant, are wrong....
In flash 8 you can, here is the code

import flash.net.FileReference;
var listener:Object = new Object();

listener.onSelect = function(file:FileReference):Void {
trace("Opened " + file.name);
}

listener.onCancel = function(file:FileReference):Void {
trace("User cancelled");
}

var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
fileRef.browse();

Xeef
03-26-2006, 10:55 AM
some are just wana by smarter ;)

in front if some body wana sugest F8 filereference
there is no way to get the Path out of it ! just the file name !
eg :
C:bla/mytext.txt --> mytext.txt
E:somethingelse/mytext.txt --> mytext.txt

coud you please show me how you use this to load (NOT UPload) let's say a text file from the harddrive ????

as you just have the file name you CAN'T !!!

but of course i am ready to learn
so show me how you wana do it ;)

spriggan
03-29-2006, 12:05 PM
This is also the MX 2004 help forum, so we have to assume the person asking the question does not have flash 8.

You can do it with PHP as well though I have no idea if it would be any better then the JS method since I've never actually tried to do it before.

Xeef
03-29-2006, 12:21 PM
No you can't do it whit PHP !

;)

PHP is server side ! and hase no access to the local hardDrive !
as long it's not runing on the local computer
and if it's runing on the local computer then the local computer is a server :p

spriggan
03-29-2006, 12:26 PM
I'm fairly sure you can with PHP since you can create file upload systems that allow you to browse the user's hard drive for files.

Xeef
03-29-2006, 12:39 PM
I'm fairly sure you can with PHP since you can create file upload systems that allow you to browse the user's hard drive for files.

no not realy

you create the upload part in javascript wich is then parsed by PHP
but not the PHP part is doing the file browsing BUT JS ;)

spriggan
03-30-2006, 07:05 AM
I'll take your word for it, I havn't had the chance to create my own PHP upload system yet. ;)

sraelgaiznaer
09-22-2006, 03:14 AM
Those who say you cant, are wrong....
In flash 8 you can, here is the code

import flash.net.FileReference;
var listener:Object = new Object();

listener.onSelect = function(file:FileReference):Void {
trace("Opened " + file.name);
}

listener.onCancel = function(file:FileReference):Void {
trace("User cancelled");
}

var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
fileRef.browse();


where do i put this code and what are the things i need?