Solved

Use Windows FileOpen dialogue in ASP (preferably with VbScript)

Posted on 2007-03-26
15
303 Views
Last Modified: 2008-01-09
I need to have a page (.ASP) that allows the user to use the standard Windows dialogue to select one or more files from their drives.

I have seen snippets of code to do this, but I haven't seen a complete example, and the snippets don't work (or I haven't been able to implement them successfully).

Can someone please post an example that will display the FileOpen dialogue when a button is pressed, and return one or more filepaths as a result.

I would prefer VbScript for this, however JavaScript would be acceptable as well.
           thanks,
                     PvBredow
0
Comment
Question by:PvBredow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +1
15 Comments
 
LVL 12

Accepted Solution

by:
Sinoj Sebastian earned 168 total points
ID: 18792026
You mean File Field?
<INPUT id="File1" type="file" name="File1">
0
 
LVL 12

Expert Comment

by:Sinoj Sebastian
ID: 18792037
>I have seen snippets of code to do this
can we have it?
0
 
LVL 25

Expert Comment

by:kevp75
ID: 18792574
I haven't seen it with vbScript, however Ihave with Javascript....

http://the-stickman.com/web-development/javascript/upload-multiple-files-with-a-single-file-element/
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 

Author Comment

by:PvBredow
ID: 18797116
Thanks for the replies.

<INPUT id="File1" type="file" name="File1">
is very CLOSE to what I am looking for, except for the (apparent) limitation that unlike the Windows Dialogue, it does NOT allow the user to select multiple files.        In my application, it is probable that many files would need to be selected, and although they would all be from the same directory, not all files in that directory could be selected.

           PvBredow
0
 
LVL 25

Expert Comment

by:kevp75
ID: 18797158
have a look at the link I posted.  I tried it, and it works.

I also use a (similar) method.  Minor exceptions though, what I do is force the client to selct the number of files they want to upload from a drop-down.  Once selected, that # of file fields appear (magically) on the page allowing them to browse for the files.  Problem is, they can only browse one at a time...

Very effective though, gives me great control over the number of files a client can upload....I mean, who really wants some yahoo coming to their site and trying to upload 140,000 files through one dialoge...
0
 

Author Comment

by:PvBredow
ID: 18798259
Thanks Kevp75.        

Am I mistaken in thinking that the actual windows dialogue can be called (as an ActiveX object)?  

Although I see the usefulness of the method you are suggesting, I would still prefer not to require the user to need to input the number of files they want to upload.        I have used the windows dialogue in VBA applications, and I am feeling a bit stubborn about trying to find a solution that works for multiple files in a single selection.

0
 
LVL 25

Expert Comment

by:kevp75
ID: 18799557
Have you gotten a chance to check out that link?
0
 

Author Comment

by:PvBredow
ID: 18806609
Yes, I have looked at the example link you sent.       I think that method would be useful on a small scale, but in my application the scale may not always be small.

Essentially, my application is a document repository for use in a company.     I need to give users a simple way to 'enrol' files in the system.      As all files are on the same LAN, I don't really need to upload them, but I do need to make a reference of their addresses.        In the long run, files are likely be to added a few at a time, but as the system is being rolled out, users are likely to want to add large numbers of files, although not necessarily all in a directory.         This is why I am determined to try to pursue the idea of something like the windows fileopen dialogue, which allows mutliple file selection with click, shift-click, or control-click.

Still, thanks for the suggestion.
0
 
LVL 25

Assisted Solution

by:kevp75
kevp75 earned 166 total points
ID: 18807576
0
 

Author Comment

by:PvBredow
ID: 18922974
I haven't found a suitable solution yet.       If there are no further suggestions, I will leave my application as it is, and simply force all files to be selected one at a time.

Thanks for the suggestions.
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 166 total points
ID: 19125113
I have used the Windows Common Dialog in an HTA application using VBScript.  Here is the code:
Const intForReading = 1

Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "Text Files (*.txt,*.log)|*.txt;*.log|All Files (*.*)|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = "."
intResult = objDialog.ShowOpen

If intResult = 0 Then
    Exit Function
End If

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile (objDialog.FileName, intForReading)
Do Until objFile.AtEndOfStream
    strSingleLine = objFile.ReadLine
      ' Do some stuff with each line
Loop
objFile.Close

Set objFile = Nothing
Set objFSO = Nothing

I hope you find that useful for your application.

Regards,

Rob.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 19125117
I haven't tested if this allows multiple files to be selected at once however.....maybe I will in due time, but it may return them as an array, or a comma separated list....

Regards,

Rob.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question