ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development
ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!

Download and Activate to enter!
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.
Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.

Download to Enter | Contest Rules

Learn More!

Tutorials | Forums

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 15th, 2007, 06:08 AM
briandecosta briandecosta is offline
liketechstuff
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 155 briandecosta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 2 h 58 m 13 sec
Reputation Power: 6
Arrow Upload - Shadow Uploader - Code just hangs and nothing gets uploaded

Hi, I am trying out the ShadowUpload script for the first time for uploading photos etc. I place the ShadowUpload script, upolad page that goes with the script in the wwwroot and then made a folder with full read/write permissions enable called uploads. When I tried to upload a large picture, it gives me the expected error

Quote:
sample code using this upload script: Code: found 1 files...
file name: CIMG6060.JPG
file type: image/pjpeg
file size: 431914
image width: 2000
image height: 1500
image to big, not saving!
--------------------------------------------------------------------------------
thank you,


However when the file size of the jpg is correct and below 200 x 200 pixels, the code just hangs and nothing gets uploaded.

the sample test upload form I am using is

Code:
<!-- #include file="ShadowUploader.asp" -->
<%
Dim objUpload
If Request("action")="1" Then
	Set objUpload=New ShadowUpload
	If objUpload.GetError<>"" Then
		Response.Write("sorry, could not upload: "&objUpload.GetError)
	Else  
		Response.Write("found "&objUpload.FileCount&" files...<br />")
		For x=0 To objUpload.FileCount-1
			Response.Write("file name: "&objUpload.File(x).FileName&"<br />")
			Response.Write("file type: "&objUpload.File(x).ContentType&"<br />")
			Response.Write("file size: "&objUpload.File(x).Size&"<br />")
			Response.Write("image width: "&objUpload.File(x).ImageWidth&"<br />")
			Response.Write("image height: "&objUpload.File(x).ImageHeight&"<br />")
			If (objUpload.File(x).ImageWidth>200) Or (objUpload.File(x).ImageHeight>200) Then
				Response.Write("image to big, not saving!")
			Else  
				Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), "")
				Response.Write("file saved successfully!")
			End If
			Response.Write("<hr />")
		Next
		Response.Write("thank you, "&objUpload("name"))
	End If
End If
%>
<form action="<%=Request.ServerVariables( "Script_Name" )%>?action=1" enctype="multipart/form-data" method="POST">
File1: <input type="file" name="file1" /><br />
File2: <input type="file" name="file2" /><br />
File3: <input type="file" name="file3" /><br />
Name: <input type="text" name="name" /><br />
<button type="submit">Upload</button>
</form>


unedited.

The ShadowUpload sript is the original unedited one ithat you posted ie

Code:
<%
'constants:
Const MAX_UPLOAD_SIZE=1500000 'bytes
Const MSG_NO_DATA="nothing to upload!"
Const MSG_EXCEEDED_MAX_SIZE="you exceeded the maximum upload size!"
Const SU_DEBUG_MODE=False

Class ShadowUpload
	Private m_Request
	Private m_Files
	Private m_Error
	
	Public Property Get GetError
		GetError = m_Error
	End Property
	
	Public Property Get FileCount
		FileCount = m_Files.Count
	End Property
	
	Public Function File(index)
		Dim keys
		keys = m_Files.Keys
		Set File = m_Files(keys(index))
	End Function
	
	Public Default Property Get Item(strName)
		If m_Request.Exists(strName) Then
			Item = m_Request(strName)
		Else  
			Item = ""
		End If
	End Property
	
	Private Sub Class_Initialize
		Dim iBytesCount, strBinData
		
		'first of all, get amount of uploaded bytes:
		iBytesCount = Request.TotalBytes
     		
		WriteDebug("initializing upload, bytes: " & iBytesCount & "<br />")
		
		'abort if nothing there:
		If iBytesCount=0 Then
			m_Error = MSG_NO_DATA
			Exit Sub
		End If
		
		'abort if exceeded maximum upload size:
		If iBytesCount>MAX_UPLOAD_SIZE Then
			m_Error = MSG_EXCEEDED_MAX_SIZE
			Exit Sub
		End If
		
		'read the binary data:
		strBinData = Request.BinaryRead(iBytesCount)
		
		'create private collections:
		Set m_Request = Server.CreateObject("Scripting.Dictionary")
		Set m_Files = Server.CreateObject("Scripting.Dictionary")
     		
		'populate the collection:
		Call BuildUpload(strBinData)
	End Sub
	
	Private Sub Class_Terminate
		Dim fileName
		If IsObject(m_Request) Then
			m_Request.RemoveAll
			Set m_Request = Nothing
		End If
		If IsObject(m_Files) Then
			For Each fileName In m_Files.Keys
				Set m_Files(fileName)=Nothing
			Next
			m_Files.RemoveAll
			Set m_Files = Nothing
		End If
	End Sub
	
	Private Sub BuildUpload(ByVal strBinData)
		Dim strBinQuote, strBinCRLF, iValuePos
		Dim iPosBegin, iPosEnd, strBoundaryData
		Dim strBoundaryEnd, iCurPosition, iBoundaryEndPos
		Dim strElementName, strFileName, objFileData
		Dim strFileType, strFileData, strElementValue
		
		strBinQuote = AsciiToBinary(chr(34))
		strBinCRLF = AsciiToBinary(chr(13))
		
		'find the boundaries
		iPosBegin = 1
		iPosEnd = InstrB(iPosBegin, strBinData, strBinCRLF)
		strBoundaryData = MidB(strBinData, iPosBegin, iPosEnd-iPosBegin)
		iCurPosition = InstrB(1, strBinData, strBoundaryData)
		strBoundaryEnd = strBoundaryData & AsciiToBinary("--")
		iBoundaryEndPos = InstrB(strBinData, strBoundaryEnd)
		
		'read binary data into private collection:
		Do until (iCurPosition>=iBoundaryEndPos) Or (iCurPosition=0)
			'skip non relevant data...
			iPosBegin = InstrB(iCurPosition, strBinData, AsciiToBinary("Content-Disposition"))
			iPosBegin = InstrB(iPosBegin, strBinData, AsciiToBinary("name="))
			iValuePos = iPosBegin
			
			'read the name of the form element, e.g. "file1", "text1"
			iPosBegin = iPosBegin+6
			iPosEnd = InstrB(iPosBegin, strBinData, strBinQuote)
			strElementName = BinaryToAscii(MidB(strBinData, iPosBegin, iPosEnd-iPosBegin))
			
			'maybe file?
			iPosBegin = InstrB(iCurPosition, strBinData, AsciiToBinary("filename="))
			iPosEnd = InstrB(iPosEnd, strBinData, strBoundaryData)
			If (iPosBegin>0) And (iPosBegin<iPosEnd) Then
				'skip non relevant data..
				iPosBegin = iPosBegin+10
				
				'read file name:
				iPosEnd = InstrB(iPosBegin, strBinData, strBinQuote)
				strFileName = BinaryToAscii(MidB(strBinData, iPosBegin, iPosEnd-iPosBegin))
				
				'verify that we got name:
				If Len(strFileName)>0 Then
					'create file data:
					Set objFileData = New FileData
					objFileData.FileName = strFileName
					
					'read file type:
					iPosBegin = InstrB(iPosEnd, strBinData, AsciiToBinary("Content-Type:"))
					iPosBegin = iPosBegin+14
					iPosEnd = InstrB(iPosBegin, strBinData, strBinCRLF)
					strFileType = BinaryToAscii(MidB(strBinData, iPosBegin, iPosEnd-iPosBegin))
					objFileData.ContentType = strFileType
					
					'read file contents:
					iPosBegin = iPosEnd+4
					iPosEnd = InstrB(iPosBegin, strBinData, strBoundaryData)-2
					strFileData = MidB(strBinData, iPosBegin, iPosEnd-iPosBegin)
					
					'check that not empty:
					If LenB(strFileData)>0 Then
						objFileData.Contents = strFileData
						
						'append to files collection if not empty:
						Set m_Files(strFileName) = objFileData
					Else  
						Set objFileData = Nothing
					End If
				End If
				strElementValue = strFileName
			Else  
				'ordinary form value, just read:
				iPosBegin = InstrB(iValuePos, strBinData, strBinCRLF)
				iPosBegin = iPosBegin+4
				iPosEnd = InstrB(iPosBegin, strBinData, strBoundaryData)-2
				strElementValue = BinaryToAscii(MidB(strBinData, iPosBegin, iPosEnd-iPosBegin))
			End If
			
			'append to request collection
			m_Request(strElementName) = strElementValue
			
			'skip to next element:
			iCurPosition = InstrB(iCurPosition+LenB(strBoundaryData), strBinData, strBoundaryData)
		Loop
	End Sub
	
	Private Function WriteDebug(msg)
		If SU_DEBUG_MODE Then
			Response.Write(msg)
			Response.Flush
		End If
	End Function
	
	Private Function AsciiToBinary(strAscii)
		Dim i, char, result
		result = ""
		For i=1 to Len(strAscii)
			char = Mid(strAscii, i, 1)
			result = result & chrB(AscB(char))
		Next
		AsciiToBinary = result
	End Function
	
	Private Function BinaryToAscii(strBinary)
		Dim i, result
		result = ""
		For i=1 to LenB(strBinary)
			result = result & chr(AscB(MidB(strBinary, i, 1))) 
		Next
		BinaryToAscii = result
	End Function
End Class

Class FileData
	Private m_fileName
	Private m_contentType
	Private m_BinaryContents
	Private m_AsciiContents
	Private m_imageWidth
	Private m_imageHeight
	Private m_checkImage
	
	Public Property Get FileName
		FileName = m_fileName
	End Property
	
	Public Property Get ContentType
		ContentType = m_contentType
	End Property
	
	Public Property Get ImageWidth
		If m_checkImage=False Then Call CheckImageDimensions
		ImageWidth = m_imageWidth
	End Property
	
	Public Property Get ImageHeight
		If m_checkImage=False Then Call CheckImageDimensions
		ImageHeight = m_imageHeight
	End Property
	
	Public Property Let FileName(strName)
		Dim arrTemp
		arrTemp = Split(strName, "\")
		m_fileName = arrTemp(UBound(arrTemp))
	End Property
	
	Public Property Let CheckImage(blnCheck)
		m_checkImage = blnCheck
	End Property
	
	Public Property Let ContentType(strType)
		m_contentType = strType
	End Property
	
	Public Property Let Contents(strData)
		m_BinaryContents = strData
		m_AsciiContents = RSBinaryToString(m_BinaryContents)
	End Property
	
	Public Property Get Size
		Size = LenB(m_BinaryContents)
	End Property
	
	Private Sub CheckImageDimensions
		Dim width, height, colors
		Dim strType
		
		'''If gfxSpex(BinaryToAscii(m_BinaryContents), width, height, colors, strType) = true then
		If gfxSpex(m_AsciiContents, width, height, colors, strType) = true then
			m_imageWidth = width
			m_imageHeight = height
		End If
		m_checkImage = True
	End Sub
	
	Private Sub Class_Initialize
		m_imageWidth = -1
		m_imageHeight = -1
		m_checkImage = False
	End Sub
	
	Public Sub SaveToDisk(strFolderPath, ByRef strNewFileName)
		Dim strPath, objFSO, objFile
		Dim i, time1, time2
		Dim objStream, strExtension
		
		strPath = strFolderPath&"\"
		If Len(strNewFileName)=0 Then
			strPath = strPath & m_fileName
		Else  
			strExtension = GetExtension(strNewFileName)
			If Len(strExtension)=0 Then
				strNewFileName = strNewFileName & "." & GetExtension(m_fileName)
			End If
			strPath = strPath & strNewFileName
		End If
		
		WriteDebug("save file started...<br />")
		
		time1 = CDbl(Timer)
		
		Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
		Set objFile = objFSO.CreateTextFile(strPath)
		
		objFile.Write(m_AsciiContents)
		
		'''For i=1 to LenB(m_BinaryContents)
		'''	objFile.Write chr(AscB(MidB(m_BinaryContents, i, 1)))
		'''Next          
		
		time2 = CDbl(Timer)
		WriteDebug("saving file took " & (time2-time1) & " seconds.<br />")
		
		objFile.Close
		Set objFile=Nothing
		Set objFSO=Nothing
	End Sub
	
	Private Function GetExtension(strPath)
		Dim arrTemp
		arrTemp = Split(strPath, ".")
		GetExtension = ""
		If UBound(arrTemp)>0 Then
			GetExtension = arrTemp(UBound(arrTemp))
		End If
	End Function
	
	Private Function RSBinaryToString(xBinary)
		'Antonin Foller, http://www.motobit.com
		'RSBinaryToString converts binary data (VT_UI1 | VT_ARRAY Or MultiByte string)
		'to a string (BSTR) using ADO recordset
		
		Dim Binary
		'MultiByte data must be converted To VT_UI1 | VT_ARRAY first.
		If vartype(xBinary)=8 Then Binary = MultiByteToBinary(xBinary) Else Binary = xBinary
		
		Dim RS, LBinary
		Const adLongVarChar = 201
		Set RS = CreateObject("ADODB.Recordset")
		LBinary = LenB(Binary)
		
		If LBinary>0 Then
			RS.Fields.Append "mBinary", adLongVarChar, LBinary
			RS.Open
			RS.AddNew
			RS("mBinary").AppendChunk Binary 
			RS.Update
			RSBinaryToString = RS("mBinary")
		Else  
			RSBinaryToString = ""
		End If
	End Function
	
	Function MultiByteToBinary(MultiByte)
		'© 2000 Antonin Foller, http://www.motobit.com
		' MultiByteToBinary converts multibyte string To real binary data (VT_UI1 | VT_ARRAY)
		' Using recordset
		Dim RS, LMultiByte, Binary
		Const adLongVarBinary = 205
		Set RS = CreateObject("ADODB.Recordset")
		LMultiByte = LenB(MultiByte)
		If LMultiByte>0 Then
			RS.Fields.Append "mBinary", adLongVarBinary, LMultiByte
			RS.Open
			RS.AddNew
			RS("mBinary").AppendChunk MultiByte & ChrB(0)
			RS.Update
			Binary = RS("mBinary").GetChunk(LMultiByte)
		End If
		MultiByteToBinary = Binary
	End Function
	
	Private Function WriteDebug(msg)
		If SU_DEBUG_MODE Then
			Response.Write(msg)
			Response.Flush
		End If
	End Function
	
	Private Function BinaryToAscii(strBinary)
		Dim i, result
		result = ""
		For i=1 to LenB(strBinary)
			result = result & chr(AscB(MidB(strBinary, i, 1))) 
		Next
		BinaryToAscii = result
	End Function
	
	':::::::::::::::::::::::::::::::::::::::::::::::::  ::::::::::::::::::
	':::                                                             :::
	':::  This routine will attempt to identify any filespec passed  :::
	':::  as a graphic file (regardless of the extension). This will :::
	':::  work with BMP, GIF, JPG and PNG files.                     :::
	':::                                                             :::
	':::::::::::::::::::::::::::::::::::::::::::::::::  ::::::::::::::::::
	':::          Based on ideas presented by David Crowell          :::
	':::                   (credit where due)                        :::
	':::::::::::::::::::::::::::::::::::::::::::::::::  ::::::::::::::::::
	':::::::::::::::::::::::::::::::::::::::::::::::::  ::::::::::::::::::
	':::::::::::::::::::::::::::::::::::::::::::::::::  ::::::::::::::::::
	'::: blah blah blah blah blah blah blah blah blah blah blah blah :::
	'::: blah blah blah blah blah blah blah blah blah blah blah blah :::
	'::: blah blah     Copyright *c* MM,  Mike Shaffer     blah blah :::
	'::: bh blah      ALL RIGHTS RESERVED WORLDWIDE      blah blah :::
	'::: blah blah  Permission is granted to use this code blah blah :::
	'::: blah blah   in your projects, as long as this     blah blah :::
	'::: blah blah      copyright notice is included       blah blah :::
	'::: blah blah blah blah blah blah blah blah blah blah blah blah :::
	'::: blah blah blah blah blah blah blah blah blah blah blah blah :::
	':::::::::::::::::::::::::::::::::::::::::::::::::  ::::::::::::::::::
	
	':::::::::::::::::::::::::::::::::::::::::::::::::  ::::::::::::::::::
	':::                                                             :::
	':::  This function gets a specified number of bytes from any    :::
	':::  file, starting at the offset (base 1)                      :::
	':::                                                             :::
	':::  Passed:                                                    :::
	':::       flnm        => Filespec of file to read               :::
	':::       offset      => Offset at which to start reading       :::
	':::       bytes       => How many bytes to read                 :::
	':::                                                             :::
	':::::::::::::::::::::::::::::::::::::::::::::::::  ::::::::::::::::::
	Private Function GetBytes(flnm, offset, bytes)
		Dim startPos
		If offset=0 Then
			startPos = 1
		Else  
			startPos = offset
		End If
		if bytes = -1 then		' Get All!
			GetBytes = flnm
		else
			GetBytes = Mid(flnm, startPos, bytes)
		end if
'		Dim objFSO
'		Dim objFTemp
'		Dim objTextStream
'		Dim lngSize
'		
'		Set objFSO = CreateObject("Scripting.FileSystemObject")
'		
'		' First, we get the filesize
'		Set objFTemp = objFSO.GetFile(flnm)
'		lngSize = objFTemp.Size
'		set objFTemp = nothing
'		
'		fsoForReading = 1
'		Set objTextStream = objFSO.OpenTextFile(flnm, fsoForReading)
'		
'		if offset > 0 then
'			strBuff = objTextStream.Read(offset - 1)
'		end if
'		
'		if bytes = -1 then		' Get All!
'			GetBytes = objTextStream.Read(lngSize)  'ReadAll
'		else
'			GetBytes = objTextStream.Read(bytes)
'		end if
'		
'		objTextStream.Close
'		set objTextStream = nothing
'		set objFSO = nothing
	End Function
	
	':::::::::::::::::::::::::::::::::::::::::::::::::  ::::::::::::::::::
	':::                                                             :::
	':::  Functions to convert two bytes to a numeric value (long)   :::
	':::  (both little-endian and big-endian)                        :::
	':::                                                             :::
	':::::::::::::::::::::::::::::::::::::::::::::::::  ::::::::::::::::::
	Private Function lngConvert(strTemp)
		lngConvert = clng(asc(left(strTemp, 1)) + ((asc(right(strTemp, 1)) * 256)))
	end function
	
	Private Function lngConvert2(strTemp)
		lngConvert2 = clng(asc(right(strTemp, 1)) + ((asc(left(strTemp, 1)) * 256)))
	end function
	
	':::::::::::::::::::::::::::::::::::::::::::::::::  ::::::::::::::::::
	':::                                                             :::
	':::  This function does most of the real work. It will attempt  :::
	':::  to read any file, regardless of the extension, and will    :::
	':::  identify if it is a graphical image.                       :::
	':::                                                             :::
	':::  Passed:                                                    :::
	':::       flnm        => Filespec of file to read               :::
	':::       width       => width of image                         :::
	':::       height      => height of image                        :::
	':::       depth       => color depth (in number of colors)      :::
	':::       strImageType=> type of image (e.g. GIF, BMP, etc.)    :::
	':::                                                             :::
	':::::::::::::::::::::::::::::::::::::::::::::::::  ::::::::::::::::::
	function gfxSpex(flnm, width, height, depth, strImageType)
		dim strPNG 
		dim strGIF
		dim strBMP
		dim strType
		dim strBuff
		dim lngSize
		dim flgFound
		dim strTarget
		dim lngPos
		dim ExitLoop
		dim lngMarkerSize
		
		strType = ""
		strImageType = "(unknown)"
		
		gfxSpex = False
		
		strPNG = chr(137) & chr(80) & chr(78)
		strGIF = "GIF"
		strBMP = chr(66) & chr(77)
		
		strType = GetBytes(flnm, 0, 3)
		
		if strType = strGIF then				' is GIF
			strImageType = "GIF"
			Width = lngConvert(GetBytes(flnm, 7, 2))
			Height = lngConvert(GetBytes(flnm, 9, 2))
			Depth = 2 ^ ((asc(GetBytes(flnm, 11, 1)) and 7) + 1)
			gfxSpex = True
		elseif left(strType, 2) = strBMP then		' is BMP
			strImageType = "BMP"
			Width = lngConvert(GetBytes(flnm, 19, 2))
			Height = lngConvert(GetBytes(flnm, 23, 2))
			Depth = 2 ^ (asc(GetBytes(flnm, 29, 1)))
			gfxSpex = True
		elseif strType = strPNG then			' Is PNG
			strImageType = "PNG"
			Width = lngConvert2(GetBytes(flnm, 19, 2))
			Height = lngConvert2(GetBytes(flnm, 23, 2))
			Depth = getBytes(flnm, 25, 2)
			select case asc(right(Depth,1))
				case 0
					Depth = 2 ^ (asc(left(Depth, 1)))
					gfxSpex = True
				case 2
					Depth = 2 ^ (asc(left(Depth, 1)) * 3)
					gfxSpex = True
				case 3
					Depth = 2 ^ (asc(left(Depth, 1)))  '8
					gfxSpex = True
				case 4
					Depth = 2 ^ (asc(left(Depth, 1)) * 2)
					gfxSpex = True
				case 6
					Depth = 2 ^ (asc(left(Depth, 1)) * 4)
					gfxSpex = True
				case else
					Depth = -1
			end select
		else
			strBuff = GetBytes(flnm, 0, -1)		' Get all bytes from file
			lngSize = len(strBuff)
			flgFound = 0
			
			strTarget = chr(255) & chr(216) & chr(255)
			flgFound = instr(strBuff, strTarget)
			
			if flgFound = 0 then
				exit function
			end if
			
			strImageType = "JPG"
			lngPos = flgFound + 2
			ExitLoop = false
			
			do while ExitLoop = False and lngPos < lngSize
				do while asc(mid(strBuff, lngPos, 1)) = 255 and lngPos < lngSize
					lngPos = lngPos + 1
				loop
				
				if asc(mid(strBuff, lngPos, 1)) < 192 or asc(mid(strBuff, lngPos, 1)) > 195 then
					lngMarkerSize = lngConvert2(mid(strBuff, lngPos + 1, 2))
					lngPos = lngPos + lngMarkerSize  + 1
				else
					ExitLoop = True
				end if
			loop
			
			if ExitLoop = False then
				Width = -1
				Height = -1
				Depth = -1
			else
				Height = lngConvert2(mid(strBuff, lngPos + 4, 2))
				Width = lngConvert2(mid(strBuff, lngPos + 6, 2))
				Depth = 2 ^ (asc(mid(strBuff, lngPos + 8, 1)) * 8)
				gfxSpex = True
			end if
		end if
	End Function
End Class
%>


anyone have any suggestions of what might be wrong. I am not getting an actual error message, but the pc processor usage seems to go a little crazy when it is trying to execute the script with the correct file size.

Reply With Quote
  #2  
Old August 15th, 2007, 06:17 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
disable the Script Blocking of the Norton AntiVirus you have installed:
http://service1.symantec.com/SUPPOR...001082912274906
after that, Restart your computer and try again.

Reply With Quote
  #3  
Old August 15th, 2007, 09:22 AM
briandecosta briandecosta is offline
liketechstuff
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 155 briandecosta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 2 h 58 m 13 sec
Reputation Power: 6
Arrow still hanging!

Thanks for the advice below. I did have script blocking checked on, so I unchecked NAV script blocking. I then tried to upload a normal sized picture, and the server just appeared to hang. With the correct sized picture upload, it gives the expected error message. Is there any way of debugging this to find out what step it is hangin at?

Cheers,


Quote:
Originally Posted by Shadow Wizard
disable the Script Blocking of the Norton AntiVirus you have installed:
http://service1.symantec.com/SUPPOR...001082912274906
after that, Restart your computer and try again.

Last edited by briandecosta : August 15th, 2007 at 09:22 AM. Reason: mispelled something

Reply With Quote
  #4  
Old August 15th, 2007, 09:56 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
I can tell you the line, but it's pointless.. it hangs when trying
to Open the file or Write to the file.
you either didn't really disable the Script Blocking, or didn't
Restart your computer - note that disabling the real time protection
is not relevant and won't help.
Comments on this post
mehere agrees: RRF ...

Reply With Quote
  #5  
Old August 15th, 2007, 11:48 AM
briandecosta briandecosta is offline
liketechstuff
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 155 briandecosta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 2 h 58 m 13 sec
Reputation Power: 6
Thumbs up worked Great!

thanks for that suggestion. Turning off the script blocking and the reboot did the trick.



Quote:
Originally Posted by Shadow Wizard
I can tell you the line, but it's pointless.. it hangs when trying
to Open the file or Write to the file.
you either didn't really disable the Script Blocking, or didn't
Restart your computer - note that disabling the real time protection
is not relevant and won't help.

Reply With Quote
  #6  
Old August 16th, 2007, 04:15 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
cheers, I've added reference to this thread in the section "Related Threads"
of the ShadowUpload main thread.

Reply With Quote
  #7  
Old August 17th, 2007, 09:56 PM
briandecosta briandecosta is offline
liketechstuff
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 155 briandecosta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 2 h 58 m 13 sec
Reputation Power: 6
Arrow need to change uploaded image name to id number

Quote:
Originally Posted by Shadow Wizard
cheers, I've added reference to this thread in the section "Related Threads"
of the ShadowUpload main thread.


Thanks a lot for that. It is working very well. I had a couple more questions. I am able to display the images on the following page: The code in red shows the image in the "uploads" folder. The first issue is using this, I am only able to show image files with the JPEG extension. I wanted to know an approach to make a generic statement that would enable it to show JPG, GIF and PNG images without having to add 3 sepate image links for each extension type.

Code:
<%@LANGUAGE=VBScript%>
<%Function LinkURLs(tempTxt)
  	Dim regEx
  	Set regEx = New RegExp
  	regEx.Global = True
  	regEx.IgnoreCase = True

  	'Hyperlink Email Addresses
  	regEx.Pattern = "([_.a-z0-9-]+@[_.a-z0-9-]+\.[a-z]{2,3})" 
  	tempTxt = regEx.Replace(tempTxt, "<a href=""mailto:$1"" class=""bluebold"">$1</a>")

  	'Hyperlink URL's
  	regEx.Pattern = "((www\.|(http|https|ftp|news|file)+\:\/\/)[_.a-z0-9-]+\.[a-z0-9\/_:@=.+?,##%&~-]*[^.|\'|\# |!|\(|?|,| |>|<|;|\)])"
  	tempTxt = regEx.Replace(tempTxt, "<a href=""$1"" class=""bluebold"" target=""_blank"">$1</a>")          

  	'Make <a href="www = <a href="http://www
  	tempTxt = Replace(tempTxt, "href=""www", "href=""http://www")

  	LinkURLs = tempTxt
End Function
%>
<%
' Define variables
dim recordsonpage, requestrecords, offset, allrecords, hiddenrecords, showrecords, lastrecord, recordcounter, pagelist, pagelistcounter

' DB connection
dim Conn
Set Conn = Server.CreateObject("ADODB.Connection")
  sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  "Data Source=" & Server.MapPath("boards.mdb") & ";" & _
  "Persist Security Info=True"
Conn.Open(sConnection)

' records per page
recordsonpage = 1

' count all records
allrecords = 0
set rs = conn.Execute("SELECT id, subject, indication, notes FROM notes where indication LIKE '%applicable%'")
do until rs.EOF
  allrecords = allrecords + 1
  rs.movenext
loop

' if offset is zero then the first page will be loaded
offset = request.querystring("offset")
if offset = 0 OR offset = "" then
  requestrecords = 0
else
  requestrecords = requestrecords + offset
end if

' opens database
set rs = conn.Execute("SELECT id, subject,indication, notes FROM notes where indication LIKE '%applicable%' ORDER BY id")

' reads first records (offset) without showing them
hiddenrecords = requestrecords
do until hiddenrecords = 0 OR rs.EOF
  hiddenrecords = hiddenrecords - 1
  rs.movenext
  if rs.EOF then
    lastrecord = 1
  end if
loop
%>

<html>
 <head>
  <title>ALL RADIOLOGY NOTES</title>
  <meta http-equiv="author" content="Tranzity">
 </head>
<body bgcolor="#000080">
<p>
</table>

<table align="center" cellspacing="2" cellpadding="2" border="1" width="800">
 <tr>
  <td><% if requestrecords <> 0 then %><a href="notesformatted.asp?offset=<% = requestrecords - recordsonpage %>"><font color=#FFFFFF>Prev Page</font></a><% else %><font color=#FFFFFF>Prev Page</font><% end if %></td>
  <td><% if lastrecord <> 1 then %>    <a href="notesformatted.asp?offset=<% = requestrecords + recordsonpage %>">Next Page</a><% else %><font color=#FFFFFF>Next Page</font><% end if %></td>
 </tr>
<%
pagelist = 0
pagelistcounter = 0
do until pagelist > allrecords  
  pagelistcounter = pagelistcounter + 1
%>
<a href="notesformatted.asp?offset=<% = pagelist %>"><% = pagelistcounter %></a>
<%
  pagelist = pagelist + recordsonpage
loop
%>
  </td>
</table>
</p>

<table cellspacing="0" cellpadding="0" border="0" width="800">

<%
' prints records in the table
showrecords = recordsonpage
recordcounter = requestrecords
do until showrecords = 0 OR rs.EOF
recordcounter = recordcounter + 1
%>
<%
Session("id")=rs("id")
%>
<tr>
  <td><span style="text-transform: uppercase"><b><font color="#FFFFFF" size="5">SUBJECT: <% = rs("subject") %></b></span><br></td>
 </tr>
<tr>
<tr>
  <td><input type="button" value="Upload JPEG"
onclick="window.open('upload.asp')"></td>
 </tr>
<tr>
  <td><img src="uploads/<%=rs("id") %>.JPG"><br></td>
 </tr>
<form method="post" action="displaynotes2.asp?print=yes"><tr>
<input type="hidden" name="ID" value="<%=rs("id")%>">
<input type="submit" name="Submit" value="Printable Format"></tr>
</form>
 <tr>
  <td><font color="#FFFFFF" size="5"><b>QUOTE:</b><br> <cite>"<%=replace((LinkURLs(rs("notes"))), vbcrlf, "<br>") %>"</cite></font></td>
 </tr>

<%
  showrecords = showrecords - 1
  rs.movenext
  if rs.EOF then
    lastrecord = 1
  end if
loop
%>



<%
' Closes connection
rs.close
Conn.close
%>

</body>
</html>


i created a Session variable for the id number of the record (in lime green in the above script)
the second question concerns adding the id value to the upload form script. I was trying to figure out how to have the uploaded image named as the id number from the session variable iinstead of whatever name it happens to have. Ie if its name is say familypic.JPG, i want the name to come up as say 6.JPG if the id passed from the previous page is 6. That way ie I can tie the image to the page without having to change its name to the id number prior to uploading. Any ideas would be great.




the upload form that I am trying is the example by Shadowiz:

Code:
<!-- #include file="ShadowUploader.asp" -->
<%
Dim objUpload

If Request("action")="1" Then
	Set objUpload=New ShadowUpload
	If objUpload.GetError<>"" Then
		Response.Write("sorry, could not upload: "&objUpload.GetError)
	Else  
		Response.Write("found "&objUpload.FileCount&" files...<br />")
		For x=0 To objUpload.FileCount-1
			Response.Write("file name: "&objUpload.File(x).FileName&"<br />")
			Response.Write("file type: "&objUpload.File(x).ContentType&"<br />")
			Response.Write("file size: "&objUpload.File(x).Size&"<br />")
			Response.Write("image width: "&objUpload.File(x).ImageWidth&"<br />")
			Response.Write("image height: "&objUpload.File(x).ImageHeight&"<br />")
			If (objUpload.File(x).ImageWidth>200) Or (objUpload.File(x).ImageHeight>200) Then
				Response.Write("image to big, not saving!")
			Else  
				Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), "")
				Response.Write("file saved successfully!")
			End If
			Response.Write("<hr />")
		Next
		Response.Write("thank you, "&objUpload("name"))
	End If
End If
%>
<form action="<%=Request.ServerVariables( "Script_Name" )%>?action=1" enctype="multipart/form-data" method="POST">
File1: <input type="file" name="file1" /><br />
File2: <input type="file" name="file2" /><br />
File3: <input type="file" name="file3" /><br />
Name: <input type="text" name="name" /><br />
<button type="submit">Upload</button>
</form>

Reply With Quote
  #8  
Old August 19th, 2007, 03:14 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
to save the file with different name, have such code:
Code:
Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), Session("id"))

as for your first question, it's dead end. you'll need to revise the whole logic,
as you can't know in advance if the user will upload JPG, GIF, BMP or whatever
type of image. one option is to store the names in database, another option is to iterate
over all the files in the folder and show them.
Comments on this post
briandecosta agrees: thanks, that was very helpful

Reply With Quote
  #9  
Old August 19th, 2007, 02:55 PM
briandecosta briandecosta is offline
liketechstuff
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2006
Posts: 155 briandecosta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 2 h 58 m 13 sec
Reputation Power: 6
Arrow worked great.

That worked out great. It now changes the name of the files to the id of the session and saves a whole lot of work having to rename. Thanks a bunch!

Quote:
Originally Posted by Shadow Wizard
to save the file with different name, have such code:
Code:
Call objUpload.File(x).SaveToDisk(Server.MapPath("Uploads"), Session("id"))

as for your first question, it's dead end. you'll need to revise the whole logic,
as you can't know in advance if the user will upload JPG, GIF, BMP or whatever
type of image. one option is to store the names in database, another option is to iterate
over all the files in the folder and show them.

Reply With Quote
  #10  
Old August 20th, 2007, 01:52 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
Click here for more information
 
Join Date: Sep 2004
Location: Israel
Posts: 31,109 Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 29th Grade (Above 100000 Reputation Level)  Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2595929 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 3 Months 3 Weeks 2 Days 20 h 18 m 8 sec
Reputation Power: 2919
cheers, if you need help implementing the new logic for your other
issue, let us know.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > Upload - Shadow Uploader - Code just hangs and nothing gets uploaded


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 



Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap