I've got a problem. I'm writing an input form that takes a file name from the user. i want to put a button next to the text box that will open up windows explorer to ensure that there are no typos in the path. does anyone have an idea as to how i can accomplish this?

thanks in advance.

Recommended Answers

All 7 Replies

I've got a problem. I'm writing an input form that takes a file name from the user. i want to put a button next to the text box that will open up windows explorer to ensure that there are no typos in the path. does anyone have an idea as to how i can accomplish this?

thanks in advance.

Insert the following lines into your form

<input name="userfile" type="file"> <input value="Submit" type="submit" value="DoAnything"/>

I believe that's what you need

that is perfect, just one more question is there a way to tell it where to display. right now it starts at the level that the form is saved in. is there a way to start it at the root?

that is perfect, just one more question is there a way to tell it where to display. right now it starts at the level that the form is saved in. is there a way to start it at the root?

I'm not sure whether such option exists in html. I have the same question

that is perfect, just one more question is there a way to tell it where to display. right now it starts at the level that the form is saved in. is there a way to start it at the root?

Do you mean you want to specify which Folder to open up in explorer when a user clicks on the "Browse" button for the File upload form element?

If so, I dont believe this is possible but would like to know if it is. Internet explorer has some file access functions that is availble to javascript (uses ActiveX so requires permission from user) that allows you to build custom file upload boxes i believe. I havent tested this but I've seen it implemented.

For a regular file upload element however, html or javascript cannot access the explorer folders as a security issue. Otherwise you will be able to look into filesystems on remote computers.
The value of the upload form element is read only so you wont be able to set it with JavaScript either.

I've done some more research and everything that i've found says that it isn't possible to give explorer a certain folder to open to. i have found, however, an attribute that allows you to filter certain file types.. &quot;accept=&quot;text/html,text/pdf&quot; but when i put that in the input tag it doesn't change anything, i can still see my php files in explorer. Any ideas on how to make this work so that the user cannot see the php files?

Some browse buttons take suggestions... If you prefill the value in the body then click browse it starts from that point.

It's not consistant, and because of remote code execution possibilities most likely /not/ available in your browser.

ok.. the browse part is working wonderfully, thank you very much. now one more question. I have a modify option on this form where the program reads the data base and displays a certain record. is there a way to fill that text box for the file name with the directory that is stored in the db? i've tried using value= and that does nothing. Is that because of that Security issue? Sorry to be a pain in the ass about this. thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.