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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option Explicit Problem

Status
Not open for further replies.

Airpan

Technical User
Jun 14, 2005
172
US
I am using this faq329-1869 to help me create photo upload capability for some pages I am building in ASP. However, I am receiving the following error:
Expected statement
upLoadEnd.asp, line 7
Option Explicit

Line 7 is:
Code:
<%Option Explicit%>

I did not change any of the code from what was posted on the FAQ. However, there was a disclaimer somewhere stating that I need to be running VB 5 on the server. I am using IIS with XP Pro... how do I ensure that I am running VB 5? Just wondering if that is causing the problem? If anyone wants me to post the code I can, but I literally copied it from the FAQ.

~E
 
I did not change any of the code from what was posted on the FAQ
In the FAQ <%Option Explicit%> is on Line 2, not 7 ...
 
Option Explicit" has to be at the top, after the language definition statement if there is one, before any other code, and only once.

[COLOR=black #d0d0d0]When I walk, I sometimes bump into things. I am closing my eyes so that the room will be empty.[/color]
 
I didn't understand when I originally did this that I had to literally put the code on the page as is, thought it would need to be placed in typical page tags. I have since pasted the code exactly as it is from the FAQ, and it now executes.
Thanks for the help.

~E
 
OK, I got the code to execute, but I need further assistance. I will need to change the file paths, correct? If so, I will be pointing the paths to the server where the images will be uploaded to?

Here is the code for the upLoadEnd.asp page:
Code:
<%@ Language=VBScript %>
<%Option Explicit%>
<!-- #include file="upLoadFunctions.asp" -->
<%
' Create the FileUploader
Dim Uploader, File, FileSys, FilePath
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()

' Check if any files were uploaded

If Uploader.Files.Count = 0 Then
    Response.Write "File(s) not uploaded."
Else
    ' Loop through the uploaded files
    For Each File In Uploader.Files.Items
        
        ' Set upload Path and Filename to check if that file already exists
        FilePath = "C:\Inetpub\[URL unfurl="true"]wwwroot\CustomerServices\Documents\"&File.FileName[/URL]
        Set FileSys = CreateObject("Scripting.FileSystemObject")

        ' If intended uploaded file already exists in the specified directory do alert and redirect previous page
        If FileSys.FileExists(FilePath) then
            Response.Write("<script>alert('Sorry FileName:"& File.FileName &" Already Used!!  Please Rename Your Local File')</script>")
            Response.Write("<script>window.location.href='upLoadStart.asp'</script>")  
        else
            ' Else Save the file
            File.SaveToDisk "C:\\Inetpub\\[URL unfurl="true"]wwwroot\\CustomerServices\\Documents"[/URL]
        end if
    Next
    ' Confirm file saved and redirect to previous page if more files to be uploaded
    Response.Write("<script>alert('File Saved')</script>")  
    Response.Write("<script>window.location.href='upLoadStart.asp'</script>")  
End If

%>

~E
 
I tried changing the file paths and still do not believe it is uploading correctly...

Code:
<%@ Language=VBScript %>
<%Option Explicit%>
<!-- #include file="upLoadFunctions.asp" -->
<%
' Create the FileUploader
Dim Uploader, File, FileSys, FilePath
Set Uploader = New FileUploader

' This starts the upload process
Uploader.Upload()

' Check if any files were uploaded

If Uploader.Files.Count = 0 Then
    Response.Write "File(s) not uploaded."
Else
    ' Loop through the uploaded files
    For Each File In Uploader.Files.Items
        
        ' Set upload Path and Filename to check if that file already exists
        FilePath = "C:\Inetpub\[URL unfurl="true"]wwwroot\aspdevelopment\photos\"&File.FileName[/URL]
        Set FileSys = CreateObject("Scripting.FileSystemObject")

        ' If intended uploaded file already exists in the specified directory do alert and redirect previous page
        If FileSys.FileExists(FilePath) then
            Response.Write("<script>alert('Sorry FileName:"& File.FileName &" Already Used!!  Please Rename Your Local File')</script>")
            Response.Write("<script>window.location.href='upLoadStart.asp'</script>")  
        else
            ' Else Save the file
            File.SaveToDisk "C:\\Inetpub\\[URL unfurl="true"]wwwroot\\aspdevelopment\\photos\\"[/URL]
        end if
    Next
    ' Confirm file saved and redirect to previous page if more files to be uploaded
    Response.Write("<script>alert('File Saved')</script>")  
    Response.Write("<script>window.location.href='upLoadStart.asp'</script>")  
End If

%>

~E
 
I was able to locate another uploader and it works great.

~E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top