Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: MOD Implementation
 Mikes File Attachment mod
 New Topic
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 3

Webbo
Average Member

United Kingdom
982 Posts

Posted - 07 April 2013 :  16:56:43  Show Profile  Visit Webbo's Homepage  Reply with Quote
I've got this mod in use in my forums and it works well


However I need to use it in a slightly different way for part of our forum so thought it would be a nice simple idea to duplicate the files and change their names slightly to keep the original files as they were, and then to have the second renamed set which I can then customise for the new purpose - it should be easy enough I thought.

The problem is when a link is clicked to bring up the renamed 'pop_upload_new.asp' - it displays correctly.
However when the form entry is then sent to the renamed 'outputFile.asp' it results in a HTTP500 error.

All three files in the mod have been renamed as such:

pop_upload_new.asp to pop_upload_new_ads.asp
outputFile.asp to outputFile_ads.asp
upload.asp to upload_ads.asp

There was one reference to the outputFile.asp file in the pop_upload_new_ads.asp file which I have changed to outputFile_ads.asp

There was one reference to uploads.asp in outputFile_ads.asp which I changed to uploads_ads.asp

and one reference to pop_upload_new.asp in outputFile_ads.asp which I have changed to pop_upload_new_ads.asp

All in all I cannot see why it should not work and yet if I use the files in their original names it does work, so it has to be something connected to the file name change, doesn't it?


Link to the original mod: http://www.snitzbitz.com/mods/details.asp?Version=All&mid=67



Help !!

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 07 April 2013 :  18:59:56  Show Profile
You missed the include.

Line 1 of outputfile.asp
Go to Top of Page

Webbo
Average Member

United Kingdom
982 Posts

Posted - 08 April 2013 :  02:20:15  Show Profile  Visit Webbo's Homepage
Nope, got that one:

<!--#include file="upload_ads.asp"-->
<!--#INCLUDE FILE="config.asp" -->
<%

It's got me baffled as it should have been so easy :)
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 08 April 2013 :  07:09:27  Show Profile
Then it has to be a permissions issue. Make sure the additional area has write permissions set for IUSR, IIS_IUSRS, & NETWORK SERVICE.
Go to Top of Page

Webbo
Average Member

United Kingdom
982 Posts

Posted - 08 April 2013 :  17:16:57  Show Profile  Visit Webbo's Homepage
I've double checked all the permissions for the 'uploaded' folder, it is the same folder that I am using to upload to with the first (original) lot of files

I've just run the files through Firefox and it resulted in this error:

Microsoft VBScript runtime error '800a004c'

Path not found

/forum/outputFile_ads.asp, line 57



Lines 55,56 & 57 read in outputFile_ads.asp:

55  'Create and Write to a File
56 pathEnd = Len(Server.mappath(Request.ServerVariables("PATH_INFO")))-14
57 Set MyFile = ScriptObject.CreateTextFile(Left(Server.mappath(Request.ServerVariables("PATH_INFO")),pathEnd) & SUBFOLDER & "\" & filename)


..which are identical to the original outputFile.asp file
and using the original files it works
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 08 April 2013 :  20:44:31  Show Profile
Between lines 56 & 57, insert this, let's see what the values show:


Response.Write pathEnd & "=pathEnd<br />" & SUBFOLDER & "=subfolder<br />" & filename & "=filename"
Go to Top of Page

Webbo
Average Member

United Kingdom
982 Posts

Posted - 09 April 2013 :  02:25:56  Show Profile  Visit Webbo's Homepage
It returns:

56=pathEnd
uploaded/Dave=subfolder
20134972118_wotno.jpg=filename

Microsoft VBScript runtime error '800a004c'

Path not found

/forum/outputFile_ads.asp, line 58



The folder exists and can be written to. The image didn't upload to the folder though
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 09 April 2013 :  08:10:49  Show Profile
Your problem is in the forward slash after "Uploaded", it has to be replaced with a backslash.

Use this command before line 57:

subfolder=replace(subfolder,"/","\")
Go to Top of Page

Webbo
Average Member

United Kingdom
982 Posts

Posted - 09 April 2013 :  13:14:33  Show Profile  Visit Webbo's Homepage
Hi Carefree, it still returns:

Microsoft VBScript runtime error '800a004c'

Path not found

/forum/outputFile_ads.asp, line 57


I tried swapping the Form Action to point to the original outputFile.asp file and it works then, however simply adding a '2' to the end of the original file name (ie outputFile2.asp) and changing the Form Action to outputFile2.asp causes the above problem..

I cannot see any other reference to the original file name in either the outputFile.asp file or the upload.asp file, so once again am baffled

Edited by - Webbo on 09 April 2013 13:19:20
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 09 April 2013 :  22:06:57  Show Profile
That makes no sense to me, either. I'll test it here.
Go to Top of Page

Classicmotorcycling
Development Team Leader

Australia
2084 Posts

Posted - 13 April 2013 :  15:47:13  Show Profile
Hello Webbo,

What happens if you change line 57 to the following:


Set MyFile = ScriptObject.CreateTextFile(Left(Server.mappath(Request.ServerVariables("PATH_INFO")),pathEnd) & strUploadUrl & "\" & SUBFOLDER & "\" & filename)


Not sure if it would work, but I found that I needed to add the strUploadUrl for one of my sites.

Cheers,

David Greening
Go to Top of Page

Webbo
Average Member

United Kingdom
982 Posts

Posted - 14 April 2013 :  17:05:58  Show Profile  Visit Webbo's Homepage
Hi David,

Nope still returns:

Microsoft VBScript runtime error '800a004c'

Path not found

/forum/outputFile_ads.asp, line 57
Go to Top of Page

Classicmotorcycling
Development Team Leader

Australia
2084 Posts

Posted - 18 April 2013 :  04:31:03  Show Profile
Hi Webbo, I worked it out for you, simply replace you outputFile_ads.asp with the below:

<!--#include file="upload_ads.asp"-->
<!--#INCLUDE FILE="config.asp" -->
<% 

subfolder = "uploaded"
iconimage = "images/icon_paperclip.gif"

  Response.Expires=0
  Response.Buffer = TRUE   
  Response.Clear
 
  byteCount = Request.TotalBytes
  RequestBin = Request.BinaryRead(byteCount)
  Dim UploadRequest
  Set UploadRequest = CreateObject("Scripting.Dictionary")
  BuildUploadRequest  RequestBin
  membername = UploadRequest.Item("memberName").Item("Value")
  subfolder = subfolder & "/" & membername
  contentType = UploadRequest.Item("blob").Item("ContentType")
  filepathname = replace(UploadRequest.Item("blob").Item("FileName"),vbNullChar,"")
  filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))
  oldfilename = filename
  filename = Year(Now) & Month(Now) & Day(Now) &  Hour(Now) & Minute(Now) & Second(Now) & "_" & filename
  
  ' --- CHECK FILE FOR ACCEPTABILITY ---
if oldfilename = "" then
	response.redirect "pop_upload_new.asp"
else
  	extension = LCase(Mid(filename,InStrRev(filename,".")))
end if

select case extension
	case ".jpg", ".jpeg", ".gif", ".zip", ".doc"
	allowFile=true
	case else
	allowFile=false
end select

  If allowFile and byteCount <= 80000 Then
  
  value = UploadRequest.Item("blob").Item("Value")

  'Create FileSytemObject Component
  Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
  memberPath = (Server.MapPath("uploaded") & "\" & membername)
    If not ScriptObject.FolderExists(memberPath) then  
	 	ScriptObject.createFolder(memberPath)
  	end if  

  'Create and Write to a File
  pathEnd = Len(Server.mappath(Request.ServerVariables("PATH_INFO")))-18
  Set MyFile = ScriptObject.CreateTextFile(Left(Server.mappath(Request.ServerVariables("PATH_INFO")),pathEnd) & SUBFOLDER & "\" & filename)
 
  For i = 1 to LenB(value)
	 MyFile.Write chr(AscB(MidB(value,i,1)))
  Next
  MyFile.Close
  
  If byteCount < 1000 Then
    strFileSize = Round(byteCount,2) & " Bytes"
  ElseIf strFileSize < 1000000 Then
    strFileSize = Round(byteCount/1000,2) & " KB"
  Else
    strFileSize = Round(byteCount/1000000,2) & " MB"
  End If

Response.Write	"<html>" & vbNewline
Response.Write	"<head>" & vbNewline
Response.Write	"<title>Upload File Result is Good</title>" & vbNewline
%>
<script>
//window.opener.PostTopic.Message.value=window.opener.PostTopic.Message.value + "\n\nImage Insert:

 <% =strFileSize %>";
window.opener.PostTopic.Message.value=window.opener.PostTopic.Message.value + "\n\nDownload Attachment: [url=\"<% =strForumURL %><% =SUBFOLDER %>/<% =filename %>\"] <% =oldfilename %>[/url]
<% =strFileSize %>";
</script>
<%
Response.Write	"</head>" & vbNewline
Response.Write	"<body bgColor=""" & strHeadCellColor & """ text=""" & strDefaultFontColor & """ link=""" & strLinkColor & """ aLink=""" & strActiveLinkColor & """ vLink=""" & strActiveLinkColor & """ onUnLoad=""window.opener.focus();"">" & vbNewline
Response.Write	"<p align=""center"">" & vbNewline
Response.Write	"	<font face=""" & strDefaultFontFace & """ size=""" & strHeadFontSize & """ color=""" & strHeadFontColor & """>The following file has been successfully recieved</font></ br><hr size=""1"" color=""" & strHiLiteFontColor & """>" & vbNewline
Response.Write	"	<table>" & vbNewline
Response.Write	"		<tr><td><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHeadFontColor & """><b> Filename </b></font></td><td> <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHiLiteFontColor & """>" & oldfilename & "</font> </td></tr>" & vbNewline
Response.Write	"		<tr><td><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHeadFontColor & """><b> Extension </b></font></td><td> <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHiLiteFontColor & """>" & extension & "</font> </td></tr>" & vbNewline
Response.Write	"		<tr><td><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHeadFontColor & """><b> Size </b></font></td><td> <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHiLiteFontColor & """>" & strFileSize & "</font> </td></tr>" & vbNewline
Response.Write	"		<tr><td><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHeadFontColor & """><b> Link </b></font></td><td> <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHiLiteFontColor & """>" & subfolder & "/" & filename & "</font> </td></tr>" & vbNewline
Response.Write	"	</table><hr size=""1"" color=""" & strHiLiteFontColor & """>" & vbNewline
Response.Write	"<a href=""#"" onClick=""window.close();"">Please click here to close this window.</a>" & vbNewline
Response.Write	"</p>" & vbNewline
Response.Write	"</body>" & vbNewline
Response.Write	"</html>" & vbNewline
Else

Response.Write	"<html>" & vbNewline
Response.Write	"<head>" & vbNewline
Response.Write	"<title>Upload File Has Errors</title>" & vbNewline
Response.Write	"</head>" & vbNewline
Response.Write	"<body bgColor=""" & strHeadCellColor & """ text=""" & strDefaultFontColor & """ link=""" & strLinkColor & """ aLink=""" & strActiveLinkColor & """ vLink=""" & strActiveLinkColor & """>" & vbNewline
Response.Write	"<p align=""center"">" & vbNewline
Response.Write	"	<font face=""" & strDefaultFontFace & """ size=""" & strHeadFontSize & """ color=""" & strHeadFontColor & """>There is a problem with the file you are attempting to upload.</font></ br><hr size=""1"" color=""" & strHiLiteFontColor & """>" & vbNewline
Response.Write	"	<table>" & vbNewline
Response.Write	"		<tr><td><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHeadFontColor & """><b> Filename </b></font></td><td> <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHiLiteFontColor & """>" & oldfilename & "</font> </td><td><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHeadFontColor & """>File names must use only valid characters</font></td></tr>" & vbNewline
Response.Write	"		<tr><td><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHeadFontColor & """><b> Extension </b></font></td><td> <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHiLiteFontColor & """>" & extension & "</font> </td><td><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHeadFontColor & """>Certain file extensions are not accepted</font></td></tr>" & vbNewline
Response.Write	"		<tr><td><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHeadFontColor & """><b> Size </b></font></td><td> <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHiLiteFontColor & """>" & Round(byteCount/1000,2) & " KB</font> </td><td><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHeadFontColor & """>File sizes must be reasonable</font></td></tr>" & vbNewline
Response.Write	"	</table><hr size=""1"" color=""" & strHiLiteFontColor & """>" & vbNewline
Response.Write	"	<a href=""#"" onClick=""history.go(-1);"">Please click here to close go back and try again.</a>" & vbNewline
Response.Write	"</p>" & vbNewline
Response.Write	"</body>" & vbNewline
Response.Write	"</html>" & vbNewline
 
End If %>



Or simply revert back to the one that you had the issues with and rather than the following, add an extra 4 to the number 14 so it is 18:

pathEnd = Len(Server.mappath(Request.ServerVariables("PATH_INFO")))-14


So it looks like this at line 51:

pathEnd = Len(Server.mappath(Request.ServerVariables("PATH_INFO")))-18


I trust that this will work for you.


Cheers,

David Greening
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 18 April 2013 :  06:19:54  Show Profile
Never noticed the len statement, good catch.
Go to Top of Page

Webbo
Average Member

United Kingdom
982 Posts

Posted - 18 April 2013 :  17:09:48  Show Profile  Visit Webbo's Homepage
Excellent, it works

What is the significance of the Len statement then, ie what did it do or not do ?
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 18 April 2013 :  22:39:07  Show Profile
The len statement specifies the LENgth of the string (in this case, the file path). When you added the "_ads" to the file names, you made the string 4 characters longer.
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Next Page
 New Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.32 seconds. Powered By: Snitz Forums 2000 Version 3.4.07