Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generating web page from shared folder 1

Status
Not open for further replies.

onyxtacular

IS-IT--Management
Mar 31, 2006
19
US
My company has tons of PDF drawings listed in folders by sales order number. I already have script to access the information, but it returns a basic folder listing back. I would like to modify this to return a webpage which will allow me to put other information in the page. This is what I have so far. Any help at all is appreciated. ...Oh yes, this script also errors out the first page with a 404 error for some reason.

Thanks,


<SCRIPT LANGUAGE="JavaScript">
<!--start stealth
function GoToURL(j) {
window.status=('Connecting....')

var URLis;
URLis = document.URLframe.Dest.value
URLHeader = "GNC3/DRAWINGS/"
if (URLis == "" || URLis.length <2= 4)
{
j.value = "Try Again"
alert('\nOops!\n\nYou must enter a valid URL');
window.status=('Missing data or Invalid. Try again?.')
}
else
{
j.value = "Connecting to: http:\\" + URLHeader + URLis
var location=window.open(" + URLHeader +
URLis,'mywindow','width=800,height=600');
this.location.href = location;
window.status=('Connecting to ' + URLHeader + URLis + ' Please
wait........');
}
}
//-->
</SCRIPT>
<FORM NAME="URLframe">
<TABLE BORDER="0" ALIGN="CENTER">
<TR>
<TD VALIGN="MIDDLE" ALIGN="CENTER">
<FONT
COLOR="#FF0000"
FACE="VERANDA,ARIAL,HELVETICA"><B>Sales Order Number: <br>
</B></FONT>
<INPUT NAME="Dest" SIZE="8" MAXLENGTH="50">
</TD>
</TR>
<TR>
<TD ALIGN="CENTER">
<P>
<INPUT TYPE="button" VALUE=" Go to.. " ONCLICK="GoToURL(this)"
onchange="refresh" WIDTH="50">
</P>
</TD>
</TR>
</TABLE>
</FORM>
 
+ URLHeader +
URLis

Dont you need a host name in the URL?

" + URLHeader +
URLis

If Dest is a filename ending in .pdf, then the average browser will start Adobe Reader to display the document. This will be in a new window due to your specification 'mywindow' in the window.open().
 
I am not sure I fully understand what you need to do but here are a couple of thoughts.
First, it sounds as if you want to read in a list of files from server folders and display them by folder/name in an HTML page. This should really be done through server-side code and you are probably going to need server-side permissions for some of what you want to do.

Second, you said the files were on a shared folder. Does this mean they are not on a web server but are on a share of a file server on your companies network? This might present other problems due to the web servers and the file servers permissions. When a web page executes server-side code it is doing so under the web servers IUSR_machinename account. That account has to have permissions on the file server for the share you want to access. This is not necessarily easy to accomplish at least with IIS servers as the authentication methods for the web server and the file server differ and would have to be altered to match which can present security issues.
I have tried accessing an Access database stored on a file server share from an ASP app and the only way to do it was to alter the IIS server's authentication methods to work with the file server's and this would not be allowed by the web server administrators. Read only access might work a bit differently but I doubt it. In any event the share has to have the IUSR_machinename account and/or possibly the IWAM_machinename account setup for access.

Of course if the files are on a web server the second issue above may not apply but then it is a matter of whether the machines are in the same domain or not, whether you have access to place scripts ON that machine so they can run with local account privledges, etc.

My guess is that you want to read the list of folders and present it on a web page with the ability to drill down into the folders and list/display the documents?


Stamp out, eliminate and abolish redundancy!
 
Hi,
Thanks for the responses:

Rac2: the domain name is my internal server - and I want to point to the virtual folder I would the contents of the folder to be a web page.

Thanks for responding...I hope this clarifies what I'm trying to accomplish


theniteowl:
"First, it sounds as if you want to read in a list of files from server folders and display them by folder/name in an HTML page. This should really be done through server-side code and you are probably going to need server-side permissions for some of what you want to do."

I have full access to the server side also.

"Second, you said the files were on a shared folder. Does this mean they are not on a web server but are on a share of a file server on your companies network?"

That is correct

"This might present other problems due to the web servers and the file servers permissions. When a web page executes server-side code it is doing so under the web servers IUSR_machinename account. That account has to have permissions on the file server for the share you want to access. This is not necessarily easy to accomplish at least with IIS servers as the authentication methods for the web server and the file server differ and would have to be altered to match which can present security issues. I have tried accessing an Access database stored on a file server share from an ASP app and the only way to do it was to alter the IIS server's authentication methods to work with the file server's and this would not be allowed by the web server administrators. Read only access might work a bit differently but I doubt it. In any event the share has to have the IUSR_machinename account and/or possibly the IWAM_machinename account setup for access."

I think I understand, suffice to say since this is will only be used for internal viewing I can change the permissions to whatever I need.

"Of course if the files are on a web server the second issue above may not apply but then it is a matter of whether the machines are in the same domain or not, whether you have access to place scripts ON that machine so they can run with local account privledges, etc.

My guess is that you want to read the list of folders and present it on a web page with the ability to drill down into the folders and list/display the documents?"

I created a virtual directory on the IIS server to point to the shared file. The users could (if the had just a bit of inclination) go the actuall shared folder by browsing to \\gnc3\DRAWINGS\235800 but since there is so many it would be easier for me (with help) to write a script to send them directly to the folder \\gnc3\DRAWINGS\235800 by inputing the 235800 and the files in the folder would be listed as links on html page along with what ever my boss wants on the page.

Thanks for responding...I hope this clarifies what I'm trying to accomplish...please respond again :)
 
You can rely on the client to type in the folder name and pass that to your script to read back the filenames or you could use a similar script to first read in the folder names and present them to the client for selection.

Try out this script. It is ASP VBAScript but I had it on hand. :)
First set the rootFolder value to one of the web server folders for testing to make certain the script is working.
Once you know it is working reading and displaying information then try setting the rootFolder to the file server folder you need to look at. If it works on the web server but fails to read from the file server then you know you have permission issues to work on.

Code:
<%
  Dim fso
  Set fso = Server.CreateObject("Scripting.FileSystemObject")
  Dim rootFolder
  Set rootFolder = fso.GetFolder("\\servername\foldername\images\")
  Dim files
  Set files = rootFolder.Files
  For Each file in files
' I used the commented lines below to filter for specific image files as I wrote this originally to read the
' names of image files into an array.
'    If file.Type <> "GIF Image" AND file.type <> "JPG Image" Then
'      Response.Write "FileName: " & file.Name & "<br>"
'    End If

' Rather than using Response.Write you could store the file info in an array or wrap it in some HTML
' to present as links to open the files.
  Response.Write UCase(file.Type)
  Response.Write "Attributes: " & file.Attributes & "<br>"
  Response.Write "Type: " & file.Type & "<br>"
  Response.Write "Size: " & file.Size & "<br>"
  Response.Write "ShortName: " & file.ShortName & "<br>"
  Next
  Set files = Nothing
  Set rootFolder = Nothing
  Set fso = Nothing
%>


Stamp out, eliminate and abolish redundancy!
 
Better yet, here is some VBA code I found and modified that will display each sub folder from the specified path and show all files underneath that folder.

Note: This loops through each sub folder then files in that folder. It does not loop through folders within the sub folders.
This should give you an idea of how to approach the project though.
Code:
<%
  Dim Fso_Obj
  Dim RootFolder
  Dim SubFolderInRoot
  Dim file
  Dim RootPath
  Dim FileExt
  Dim MyFiles
  Dim Fnum
  'Full path to parent folder you want to display.  Must have a backslash at the end.
  RootPath = "\\ismminfopp01\inetpub\[URL unfurl="true"]wwwroot\CSD\"[/URL]
 
  Set Fso_Obj = CreateObject("Scripting.FileSystemObject")
  If Fso_Obj.FolderExists(RootPath) Then
    Set RootFolder = Fso_Obj.GetFolder(RootPath)
    'Loop through the Sub Folders displaying their name.
    For Each SubFolderInRoot In RootFolder.SubFolders
      Response.Write "<H3>" & SubFolderInRoot & "</H1>" & "<br>"
      'Display name of each file in sub folder.
      For Each file In SubFolderInRoot.Files
        Response.Write file.name & "<br>"
      Next 'file
    Next
  Else
    MsgBox RootPath & "  does not exist."
  End If
%>

Stamp out, eliminate and abolish redundancy!
 
Hi niteowl:

Thanks, this code seems to be really close to what I need. So far I've gotten the folders to list out. I had to comment out the files routine, but at least I'm on the right path.
Reading the files gives me a permission denied error.
Once I tweak the permissions I should at least come out with a dir listing :)

Thanks again,

 
Well I've been playing with the permissions to the folder in question \\gnc3\drawings\ and still have not gotten pass the permission denied error. I guess what really irks me is that I can get the sub-folders to list out but not the files. When uncomment the

(line 20) For Each file In SubFolderInRoot.Files
(line 21) Response.Write file.name & "<br>"
(line 22) Next

I get

\\gnc3\drawings\235800


Microsoft VBScript runtime error '800a0046'

Permission denied

/test.asp, line 20



Here are the permission settings for \\gnc3\drawings\
IIS_WPG
INTERACTIVE
IUSR_GNC3
IWAM_GNC3
NETWORK
NETWORK SERVICE

have read & execute permissions
Any Ideas?

Thanks
 
Permissions problems are a PITA.
One possibility. The script is reading the list of folders in the drawings folder so the permissions are working in THAT folder but do the permissions extend into the sub folders?
You will see folder names because that is what exists in the drawings folder but checking the files inside those sub-folders requires permissions inside those folders as well.


Stamp out, eliminate and abolish redundancy!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top