I have script, which takes path and copy some files into it. What I want is: I want to have browse button and when user clicks it, he will be able to just select folder he wants
This just isn't possible because of security issues that would be exposed by this functionality, i.e. being able to log the user's file directories. When a user browses for a file, the dialog is created by the browser and none of this information is relayed back, only the contents of the selected file.
The only solution I can think of without hitting up ActiveX
or similar is to force the user to select a file from within their chosen directory and upload it. This has obvious drawbacks in that they may not want their files to be uploaded and also that they may not have any files within their desired folder. However, assuming that a) they have a file and b) that they don't care about how you deal with that file you can:
<form name="folderForm">
<input type=file name="file">
<input type=text name="folderLocation">
<input type=button value="Get Folder" onclick="javascript:GetFolder();">
</form>
function GetFolder() {
document.folderForm.folderLocation.value=document.folderForm.file.value;
}
Then on the server side you can parse the value of folderLocation
to remove the file name after the last /
or do this in GetFolder()
if you wish.