Author |
Topic |
|
zephyr
Starting Member
44 Posts |
Posted - 24 October 2002 : 16:38:25
|
I have installed Mike's File attachment module. But there were few validations, which were not done in Mike's , so I used ServerHacker's for that. Basically there three files for enabling the file upload functionality.
They are pop_upload_new.asp Upload.asp OutFile.asp.
I am able to upload files. No problem with that. The problem is my forum member would like to upload some compliance certficates and they would be sizing few Mega Bytes ( say up 8 MB). Could any one help me in increasing the size
Please email me, if you would like to see the files and I can send them over to you or please copy and paste the code that is available below in to your code editors and execute them.
Thanks
#######################BEGIN OUTFILE.asp#######################
<!--#include file="upload.asp"--> <!--#INCLUDE FILE="config.asp" --> <%
subfolder = "data" 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 = UploadRequest.Item("blob").Item("FileName") 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", ".txt" 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("data") & "\" & 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")))-14 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\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 %> #######################END Outfile.asp############################
#######################BEGIN UPLOAD.asp############################
<%Sub BuildUploadRequest(RequestBin) PosBeg = 1 PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13))) boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg) boundaryPos = InstrB(1,RequestBin,boundary) Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--"))) Dim UploadControl Set UploadControl = CreateObject("Scripting.Dictionary") Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition")) Pos = InstrB(Pos,RequestBin,getByteString("name=")) PosBeg = Pos+6 PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34))) Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename=")) PosBound = InstrB(PosEnd,RequestBin,boundary) If PosFile<>0 AND (PosFile<PosBound) Then PosBeg = PosFile + 10 PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34))) FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) UploadControl.Add "FileName", FileName Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:")) PosBeg = Pos+14 PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13))) ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) UploadControl.Add "ContentType",ContentType PosBeg = PosEnd+4 PosEnd = InstrB(PosBeg,RequestBin,boundary)-2 Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg) Else Pos = InstrB(Pos,RequestBin,getByteString(chr(13))) PosBeg = Pos+4 PosEnd = InstrB(PosBeg,RequestBin,boundary)-2 Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg)) End If UploadControl.Add "Value" , Value UploadRequest.Add name, UploadControl BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary) Loop End Sub Function getByteString(StringStr) For i = 1 to Len(StringStr) char = Mid(StringStr,i,1) getByteString = getByteString & chrB(AscB(char)) Next End Function Function getString(StringBin) getString ="" For intCount = 1 to LenB(StringBin) getString = getString & chr(AscB(MidB(StringBin,intCount,1))) Next End Function%> #########################END Upload.asp#############################
###################BEGIN Pop_upload_new.asp####################### <!--#INCLUDE FILE="config.asp" --> <!--#INCLUDE file="inc_func_common.asp" --> <!--#INCLUDE file="inc_header_short.asp" --> <body background="images/mainsiteback2.gif" <% if strDBNTUserName <> "" then if Request("Method_Type") = "Write_Configuration" then Err_Msg = Request.QueryString("Err_Msg")
if Err_Msg <> "" then
Response.Write "<p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """>There Was A Problem With Your Details</font></p>" & vbNewline & _ "<table bgColor=""" & strHeadCellColor & """ align=""center"" border=""0"">" & vbNewline & _ " <tr>" & vbNewline & _ " <td><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """ color=""" & strHeadFontColor & """>" & vbNewline & _ " <ul>" & vbNewline & _ "" & Err_Msg &"" & vbNewline & _ " </ul>" & vbNewline & _ " </font>" & vbNewline & _ " </td>" & vbNewline & _ " </tr>" & vbNewline & _ " <tr>" & vbNewline & _ " <td align=""center"">" & vbNewline & _ " <font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><a href=""#"" onclick=""javascript:history.go(-1)"">Go Back To Enter Data</a></font>" & vbNewline & _ " </td>" & vbNewline & _ " </tr>" & vbNewline & _ "</table>" & vbNewline end if else Response.Write "<table bgColor=""" & strHeadCellColor & """ valign=""center"" width=""95%"" height=""95%"">" & vbNewline & _ " <tr>" & vbNewline & _ " <td align=""center"" width=""100%"">" & vbNewline & _ " <FORM METHOD=""Post"" ENCTYPE=""multipart/form-data"" ACTION=""outputFile.asp"">" & vbNewline & _ " <font face=""" & strDefaultFontFace & """ size=""" & strHeadFontSize & """ color=""" & strHeadFontColor & """><b>File: </b></font><INPUT TYPE=""file"" NAME=""blob"" size=""40""><BR><br>" & vbNewline & _ " <input type=""hidden"" name=""memberName"" value=""" & strDBNTUserName & """>" & vbNewline & _ " <INPUT TYPE=""submit"" NAME=""Enter"" value=""Upload File to " & strDBNTUserName & "'s post"" onclick=""value='Wait.. Uploading Image..';""></p>" & vbNewline & _ " </FORM>" & vbNewline & _ " </td>" & vbNewline & _ " </tr>" & vbNewline & _ "</table>" & vbNewline end if else Response.Write "<p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>You must be logged in to use this page</font></p>" & vbNewline end if %> <!--#INCLUDE file="inc_footer_short.asp" --> #########################END pop_upload_new.asp################# |
Edited by - zephyr on 24 October 2002 16:46:03 |
|
dayve
Forum Moderator
USA
5820 Posts |
Posted - 25 October 2002 : 01:21:57
|
asp upload scripts can tend to time out with larger files but you can edit this line:
If allowFile and byteCount <= 80000 Then
you may want to post a text link to your code next time... just a tip.
|
|
|
|
be4you
New Member
61 Posts |
Posted - 01 November 2002 : 15:32:46
|
Get this error message when I try to upload files to forum:
There is a problem with the file you are attempting to upload.
-------------------------------------------------------------------------------- Filename Audi A4_6.jpg File names must use only valid characters Extension .jpg Certain file extensions are not accepted Size 124.06 KB File sizes must be reasonable
-------------------------------------------------------------------------------- Please click here to close go back and try again.
Anyone?? |
|
|
be4you
New Member
61 Posts |
Posted - 02 November 2002 : 13:40:10
|
Anyone?? |
|
|
ajhvdb
Junior Member
Netherlands
392 Posts |
Posted - 02 November 2002 : 15:26:42
|
Do all filenames give this error? Look in the source for this errormessage and find out why the message is displayed. |
|
|
barky81
Junior Member
USA
166 Posts |
Posted - 02 November 2002 : 17:38:44
|
My guess is that you are trying to upload into a directory for which you don't have write permission--at least that is when I get it.
Is this your own server under your local control? (If so, check the logs.)
quote: Originally posted by be4you
Get this error message when I try to upload files to forum:
There is a problem with the file you are attempting to upload.
-------------------------------------------------------------------------------- Filename Audi A4_6.jpg File names must use only valid characters Extension .jpg Certain file extensions are not accepted Size 124.06 KB File sizes must be reasonable
-------------------------------------------------------------------------------- Please click here to close go back and try again.
Anyone??
|
|
|
Classicmotorcycling
Development Team Leader
Australia
2084 Posts |
Posted - 02 November 2002 : 18:43:43
|
This could also be the size of the file you are trying to upload. If it is only set to a small amount of 80K (If allowFile and byteCount <= 80000 Then ) then you will also get that error. If you want it to be 8Mb then you will need to set it to:
If allowFile and byteCount <= 8000000 Then
I have the default set to a small amount as it cause grief on the performance of your site and if you are expecting 8Mb files, would it not be better for you to grab them from the customer on CD?
quote: Originally posted by barky81
My guess is that you are trying to upload into a directory for which you don't have write permission--at least that is when I get it.
Is this your own server under your local control? (If so, check the logs.)
quote: Originally posted by be4you
Get this error message when I try to upload files to forum:
There is a problem with the file you are attempting to upload.
-------------------------------------------------------------------------------- Filename Audi A4_6.jpg File names must use only valid characters Extension .jpg Certain file extensions are not accepted Size 124.06 KB File sizes must be reasonable
-------------------------------------------------------------------------------- Please click here to close go back and try again.
Anyone??
|
Cheers, David Greening |
|
|
be4you
New Member
61 Posts |
|
be4you
New Member
61 Posts |
|
|
Topic |
|
|
|