简体   繁体   中英

client side directory detection

Just a general question. I'm going to be creating a site and one thing that I will have to do is create a .bat file, that the user can download which is tied into a piece of software on their machine.

When the user is 'registering', one thing I would like to do is to be able to have the user select which where their specific directory is for audio files.

This is no different then clicking on "browse" for an upload and then selecting the file to be uploaded. But instead of getting the file, I'd like to be able to just collect the directory. The reason for his is because inside the bat file is an ftp command to upload an mp3 file to a server. I'd like to build the bat file on the fly for them as they register and fill in the blank area with their directory they have chosen. They then download the bat file and add the command line into the software to execute the bat file, which then uploads the newly created mp3 file to a server.

So is there a way to detect and collect the client side directory?

Here is one way to do it:

@Echo off
setlocal
Call :BrowseFolder "Choose Music folder" "C:\" r
echo %r%
pause
Goto :EOF


:BrowseFolder
setlocal
set vbs="%temp%\_.vbs"
if exist %vbs% del /f /q %vbs%
>%vbs% echo set sh=wscript.CreateObject("Shell.Application") 
>>%vbs% echo set f=sh.BrowseForFolder(0,%1,0,%2) 
>>%vbs% echo if typename(f)="Nothing" Then 
>>%vbs% echo   wscript.echo "Dialog Cancelled" 
>>%vbs% echo   wscript.Quit(1) 
>>%vbs% echo end if 
>>%vbs% echo set fs=f.Items():set fi=fs.Item() 
>>%vbs% echo p=fi.Path:wscript.echo p
for /f "tokens=*" %%a in ('cscript //nologo %vbs%') do set result=%%a
if exist %vbs% del /f /q %vbs%
if "%result%" EQU "Dialog Cancelled" (set a=1) else set a=0
endlocal & set %3=%result% & exit /b %a%

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM