View Full Version : asp form upload issue in IE - code works in Firefox
Struggling with an upload issue via form in IE. Code works in Firefox, but not in IE. IE processes, but no errors displayed in IE either and checking file upload on back end file disappeared in cyber...
Did a bunch of research online, but no luck finding anything.
Anyone know of an issue with IE form handling in classic ASP? If you like to see the code, let me know.
Thanks for reading,
Tom
Old Pedant
08-31-2010, 07:15 PM
Show the <form> where you are doing the upload from?
And whose uploader are you using? Is it a "pure ASP upload" script? If possible, avoid those. If you are using a shared hosting account, see if your web host has a commercial uploader available as part of your hosting package.
thanks much for your reply. I am not that strong with asp, but think its "pure asp upload". The script seams to be within the page itself, please see below. I am hoping to get a fix or workaround until our new site in php is implemented.
Would it be possible to split this code into a "form page" and "asp upload page" without messing to much up?
Thanks again for your comments.
Tom
Sub DocumentUpload(strDefaultUploadPath)
Dim objFSO
Dim objFolder
Dim objSubFolder1
Dim objSubFolder2
Dim objSubFolder3
Dim objSubFolder4
Dim objSubFolder5
Dim objSubFolder6
Dim objSubFolder7
Dim strValue
Dim strText
Dim strSelected
strSelected = "" 'Default setting
strDefaultUploadPath = Trim(Cstr(strDefaultUploadPath))
If right(strDefaultUploadPath, 1) = "/" then strDefaultUploadPath = Left(strDefaultUploadPath, Len(strDefaultUploadPath)-1)
%>
<P class=PageHeader>Document Upload</P>
<P align=Center><a href="test.asp?action=main">Main Menu</a></P>
<BR>
<P>Select the destination folder and browse for the files to upload</P>
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="test.asp?action=documentuploadsave" id=form2 name=form2>
<P>Destination Folder:
<SELECT id=cmbUploadFolder name=cmbUploadFolder>
<OPTION value="./library">library</OPTION>
<%
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.MapPath("./library"))
'We only look at the first 5 levels of folder.
For each objSubFolder1 in objFolder.SubFolders
strValue = "./library/" & objSubFolder1.Name
strText = right(strValue, len(strValue)-2)
If strDefaultUploadPath = "" or strDefaultUploadPath = strValue then strSelected = " SELECTED " else strSelected = ""
Response.Write("<OPTION value='" & strValue & "'" & strSelected & ">" & strText &"</OPTION>")
For each objSubFolder2 in objSubFolder1.SubFolders
strValue = "./library/" & objSubFolder1.Name & "/" & objSubFolder2.Name
strText = right(strValue, len(strValue)-2)
If strDefaultUploadPath = strValue then strSelected = " SELECTED " else strSelected = ""
Response.Write("<OPTION value='" & strValue & "'" & strSelected & ">" & strText &"</OPTION>")
For each objSubFolder3 in objSubFolder2.SubFolders
strValue = "./library/" & objSubFolder1.Name & "/" & objSubFolder2.Name & "/" & objSubFolder3.Name
strText = right(strValue, len(strValue)-2)
If strDefaultUploadPath = strValue then strSelected = " SELECTED " else strSelected = ""
Response.Write("<OPTION value='" & strValue & "'" & strSelected & ">" & strText &"</OPTION>")
For each objSubFolder4 in objSubFolder3.SubFolders
strValue = "./library/" & objSubFolder1.Name & "/" & objSubFolder2.Name & "/" & objSubFolder3.Name & "/" & objSubFolder4.Name
strText = right(strValue, len(strValue)-2)
If strDefaultUploadPath = strValue then strSelected = " SELECTED " else strSelected = ""
Response.Write("<OPTION value='" & strValue & "'" & strSelected & ">" & strText &"</OPTION>")
For each objSubFolder5 in objSubFolder4.SubFolders
strValue = "./library/" & objSubFolder1.Name & "/" & objSubFolder2.Name & "/" & objSubFolder3.Name & "/" & objSubFolder4.Name & "/" & objSubFolder5.Name
strText = right(strValue, len(strValue)-2)
If strDefaultUploadPath = strValue then strSelected = " SELECTED " else strSelected = ""
Response.Write("<OPTION value='" & strValue & "'" & strSelected & ">" & strText &"</OPTION>")
For each objSubFolder6 in objSubFolder5.SubFolders
strValue = "./library/" & objSubFolder1.Name & "/" & objSubFolder2.Name & "/" & objSubFolder3.Name & "/" & objSubFolder4.Name & "/" & objSubFolder5.Name & "/" & objSubFolder6.Name
strText = right(strValue, len(strValue)-2)
If strDefaultUploadPath = strValue then strSelected = " SELECTED " else strSelected = ""
Response.Write("<OPTION value='" & strValue & "'" & strSelected & ">" & strText &"</OPTION>")
For each objSubFolder7 in objSubFolder6.SubFolders
strValue = "./library/" & objSubFolder1.Name & "/" & objSubFolder2.Name & "/" & objSubFolder3.Name & "/" & objSubFolder4.Name & "/" & objSubFolder5.Name & "/" & objSubFolder6.Name & "/" & objSubFolder7.Name
strText = right(strValue, len(strValue)-2)
If strDefaultUploadPath = strValue then strSelected = " SELECTED " else strSelected = ""
Response.Write("<OPTION value='" & strValue & "'" & strSelected & ">" & strText &"</OPTION>")
Next
Next
Next
Next
Next
Next
Next
Set objFolder = Nothing
Set objFSO = Nothing
%>
</SELECT></P>
<P>New Subfolder: <INPUT type="text" id=txtNewSubFolder name=txtNewSubFolder> </P>
<P>Files:</P>
<INPUT TYPE="FILE" SIZE="70" NAME="FILE1"><BR>
<INPUT TYPE="FILE" SIZE="70" NAME="FILE2"><BR>
<INPUT TYPE="FILE" SIZE="70" NAME="FILE3"><BR>
<INPUT TYPE="FILE" SIZE="70" NAME="FILE4"><BR>
<INPUT TYPE="FILE" SIZE="70" NAME="FILE5"><BR>
<INPUT TYPE="FILE" SIZE="70" NAME="FILE6"><BR>
<INPUT TYPE="FILE" SIZE="70" NAME="FILE7"><BR>
<INPUT TYPE="FILE" SIZE="70" NAME="FILE8"><BR>
<INPUT TYPE="FILE" SIZE="70" NAME="FILE9"><BR>
<INPUT TYPE="FILE" SIZE="70" NAME="FILE10"><BR>
<INPUT TYPE=SUBMIT VALUE="Upload" id=SUBMIT1 name=SUBMIT1>
</FORM>
<BR>
<BR>
<P>If you just want to create a subfolder, and not upload any files, just enter the new subfolder name and click Upload.</P>
<%
End Sub
'========================================================================
Sub DocumentUploadSave()
Dim strNewSubFolder
Dim strUploadFolder
Dim objFSO
Dim blnNewFolderCreated
'Set defaults
blnNewFolderCreated = False
%>
<P align=Center><a href="test.asp?action=main">Main Menu</a></P>
<%
Set Upload = Server.CreateObject("Persits.Upload")
Count = Server.MapPath("./library")
'Response.Write("Upload destination: " & Upload.Form("cmbUploadFolder").Value & "<BR>")
'Response.Write("Mapped destination: " & Server.MapPath(Upload.Form("cmbUploadFolder").Value) & "<BR>")
strUploadFolder = Upload.Form("cmbUploadFolder").Value
strNewSubFolder = Trim(Upload.Form("txtNewSubFolder").Value)
If strNewSubFolder <> "" then
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If objFSO.folderexists(Server.MapPath(strUploadFolder) & "\" & strNewSubFolder) = True then
Response.Write("The Subfolder you wanted to create already exists. Please try again with a new Subfolder name.")
Response.End
End If
objFSO.createfolder(Server.MapPath(strUploadFolder) & "\" & strNewSubFolder)
blnNewFolderCreated = True
strUploadFolder = strUploadFolder & "/" & strNewSubFolder
Set objFolder = Nothing
Set objFSO = Nothing
End If
For each file in Upload.Files
Response.Write("<P>...saving " & file.FileName & " to " & strUploadFolder & "</P>")
Session("uAction") = "Uploaded file : " & strUploadFolder & "/" & file.FileName
AddtoLogNoRedirect()
If strUploadFolder <> "./library" then
file.MoveVirtual(strUploadFolder & "/" & file.FileName)
End If
Next
If blnNewFolderCreated = True then
Response.Write("<P>Subfolder " & strNewSubFolder & " created</P>")
End If
Response.Write("<P>UPLOAD COMPLETE - " & Count & " file(s) have been uploaded.</P>")
%>
<BR>
<P>
<A href=members.asp?action=documentupload>Upload more files</A><BR>
<A href=members.asp?action=library&dir=./library/>Browse files</A>
</P>
<%
End Sub
Old Pedant
08-31-2010, 10:54 PM
No, it's using the best uploader available:
Set Upload = Server.CreateObject("Persits.Upload")
So that's not the issue.
Might really be browser related, after all.
Do you get *ANY* output on the upload page???
wow, that was quick. There is no output in IE whatsoever, Firefox has no issues uploading. Our host uploaded a stand alone test script and this works. Full path was specified on it, so would modifying this:
Count = Server.MapPath("./library") to full path make a difference and what about security then? Or could the issue be somewhere else?
Much appreciated,
Tom
form:
h3>Simple Upload</h3>
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="UploadScript1.asp">
<INPUT TYPE="FILE" SIZE="40" NAME="FILE1"><BR>
<INPUT TYPE="FILE" SIZE="40" NAME="FILE2"><BR>
<INPUT TYPE="FILE" SIZE="40" NAME="FILE3"><BR>
<INPUT TYPE=SUBMIT VALUE="Upload!">
</FORM>
</BODY>
</HTML>
script:
%
Set Upload = Server.CreateObject("Persits.Upload")
Count = Upload.Save("C:\inetpub\vhosts\test.com\httpsdocs\secure\uploads")
Response.Write Count & " file(s) uploaded to uploads folder"
%>
Old Pedant
08-31-2010, 11:53 PM
would modifying this:
Count = Server.MapPath("./library") to full path make a difference
It could. But I assume you really mean
Count = Upload.Save( Server.MapPath("./library") )
To find out, split that into two steps and add DEBUG:
savePath = Server.MapPath("./library")
Response.Write "savePath is " & savePath & "<hr>" & vbNewLine
Count = Upload.Save( savePath )
Response.Write Count & " file(s) uploaded to uploads folder<hr>" & vbNewLine
Do that. If you still get no output from IE then we'll have to try something weirder.
I give this a try later today. Yes, there is no response write in MSIE.
Appreciate all your time.
Tom
Hmmm...Just noticed you had the line
Code:
---------
Response.Write Count & " file(s) uploaded to uploads folder"
---------
You are saying that even *THAT* doesn't appear when using MSIE????
All fixed. I ended up looking at the code line by line and sure enough was something simple. There was an extra " at two places in the code that caused this, caused issues IE but not Firefox.
Sometimes just talking through with someone else helps figure this out. Old Pedant, thanks so much for your time and suggestions.
Tom
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.