Solved

ASP Redirect Header Error

Posted on 2013-06-18
2
791 Views
Last Modified: 2013-06-19
Hello,

I am trying to complete a process (uploading images) and then move the user to another page, but I keep getting :


Response object

 error 'ASP 0156 : 80004005'

Header Error

/image_upload.asp, line 251

The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content

However, I have looked online and Response.Buffer = True etc., but simply can't get it to budge...

Here is the code of my page:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Response.Expires = 0
Response.Buffer = True
%>
<!--#include file="deps/db.asp"-->
<!--#include file="deps/mailto.asp"-->
<!-- #include file="ASPUpload/aspuploader/include_aspuploader.asp" -->
<%
PropID = request.QueryString("PropID")
UID = request.QueryString("UID")
lng = request.QueryString("lng")
lat = request.QueryString("lat")
location = request.QueryString("location")
'check user	
    if request.cookies("Villas")("UniqueID") <> "" then
	UniqueID = request.cookies("Villas")("UniqueID")
	else
	UniqueID = session("UniqueID")
	End if
	UID = Request.Querystring("UID")
	Set RS = DB.Execute("Select * from Admin where ID = " & UID & " and UniqueID = '" & UniqueID & "'")
	If RS.EOF OR RS.BOF then
	RS.Close
	Set RS = Nothing
	DB.Close
	Set DB = Nothing
	%>
    <script type="text/javascript">
	{
	  if (opener && !opener.closed) opener.location.href = "logon.asp";
	  window.close();
	}
	</script>
	<%
	else
	AUTH = RS("AUTH")
	Set PropRS = DB.Execute("Select * from villas where ID = " & PropID & " and Client_ID = " & UID)
		If NOT PropRS.EOF or AUTH = 1 Then
			PropRS.Close
			Set PropRS = Nothing
			RS.Close
			Set RS = Nothing
		else
			PropRS.Close
			Set PropRS = Nothing
			RS.Close
			Set RS = Nothing
			DB.Close
			Set DB = Nothing
			%>
	    	<script type="text/javascript">
			{
			  if (opener && !opener.closed) opener.location.href = "logon.asp";
			  window.close();
			}
			</script>
			<%
		End If
    End If 
'end check user
Set UploadProgress = Server.CreateObject("Persits.UploadProgress")
PID = "PID=" & UploadProgress.CreateProgressID()
barref = "framebar.asp?to=10&" & PID
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>VillasDirect - Villas &amp; Apartments for Rent or Sale</title>
<link href="villasdirect.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body {
	background-color: #DFEDEF;
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	text-decoration:none;
	background-image: url(images/photoupload-bkg-main.jpg);
}
</style>
<SCRIPT TYPE="text/javascript" LANGUAGE="javascript">

<!-- PreLoad Wait - Script -->
<!-- This script and more from http://www.rainbow.arch.scriptmania.com 

function waitPreloadPage() { //DOM
if (document.getElementById){
document.getElementById('prepage').style.visibility='visible';
}else{
if (document.layers){ //NS4
document.prepage.visibility = 'visible';
}
else { //IE4
document.all.prepage.style.visibility = 'visible';
}
}
}
// End -->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
function ShowProgress()
{
  strAppVersion = navigator.appVersion;
  if (document.UPLForm.FILE1.value != "" || document.UPLForm.FILE2.value != "" || document.UPLForm.FILE3.value != "" || document.UPLForm.FILE5.value != "" || document.UPLForm.FILE5.value != "")
  {
    if (strAppVersion.indexOf('MSIE') != -1 && strAppVersion.substr(strAppVersion.indexOf('MSIE')+5,1) > 4)
    {
      winstyle = "dialogWidth=385px; dialogHeight:140px; center:yes";
      window.showModelessDialog('<% = barref %>&b=IE',null,winstyle);
    }
    else
    {
      window.open('<% = barref %>&b=NN','','width=370,height=115', true);
    }
  }
  return true;
}
</SCRIPT> 
<script language = "JavaScript">
{ heavyImage = new Image();  
heavyImage.src = "images/loading.gif"; } 
</script>
<link href="demo.css" rel="stylesheet" type="text/css" />
</head>

<body bgcolor="#FFFFFF" text="#000000" Topmargin="0" Bottommargin="0" Leftmargin="0" Rightmargin="0" link="#0000FF" vlink="#0000FF" align="center" onLoad="document.all.prepage.style.visibility = 'hidden';">
<table width="607" align="left"><tr>
  <td height="536" align="center" valign="top">
<table width="500" cellpadding="0" cellspacing="0">
<tr>
  <td height="39" align="center" class="pagehead">UPLOAD YOUR PHOTOS</td>
</tr>
<tr><td width = "100%" height="445" align="center" valign="middle"><p align="center" class="para">&nbsp;</p>
  <p align="center" class="para"><B class="specialtitles">UPLOAD AS MANY PHOTOS AS YOU LIKE, ALL IN ONE GO!!</B><br />
    <BR>
    <strong>The better your photos,  the more interest you will get with your property!</strong><BR>&nbsp;<BR>You can  change the display order of your pictures once the upload has completed.</p>

<!--ASP Upload Start-->
<%
SQL = "Select * from photos where PropID = " & PropID & " Order By OrderBy DESC"
Set RS = DB.Execute(SQL)
If NOT RS.EOF then
OrderBy = RS("OrderBy")
Else
OrderBy = 1
End If
RS.Close
Set RS = Nothing

   Dim fso, msg
   Set fso = CreateObject("Scripting.FileSystemObject")
   If fso.FolderExists("C:\HostingSpaces\villas\villasdirect.com\wwwroot\villa\" & PropID) Then
   Else
   fso.CreateFolder("C:\HostingSpaces\villas\villasdirect.com\wwwroot\villa\" & PropID)
   End If
   Set fso = Nothing
UploadDirectory = "C:\HostingSpaces\villas\villasdirect.com\wwwroot\villa\" & PropID
%>

	<script type="text/javascript">
	function CuteWebUI_AjaxUploader_OnPostback() {
		//submit the form after the file have been uploaded:
		document.forms[0].submit();
	}
	</script>

	<div class="demo">                        
        <h2>Select multiple photos to upload</h2>
		<p>Please click the button below and select the photos you wish to upload - you can select multiple photos in one go.<br />
		  Your explorer window will open - simply locate the photos you wish to upload and select them- it's as easy as that!</p>
		<p>There is a 10MB limit per photo.</p>
		
			<!-- do not need enctype="multipart/form-data" -->
			<form id="form1" method="POST">
			<%
			Dim uploader
			Set uploader=new AspUploader
			uploader.MaxSizeKB=10240
			uploader.Name="myuploader"
			uploader.InsertText="Select Photos"
			uploader.MultipleFilesUpload=true
			%>
			<%=uploader.GetString() %>
			</form>
			
			<br/><br/>
<%

If Request.Form("myuploader")&""<>"" Then

	Dim list,i
	
	'Gets the GUID List of the files based on uploader name 
	list=Split(Request.Form("myuploader"),"/")

	For i=0 to Ubound(list)
		if i>0 then
			Response.Write("<hr/>")
		end if
		Dim mvcfile
		
		'get the uploaded file based on GUID
		Set mvcfile=uploader.GetUploadedFile(list(i))

		'Response.Write("<div style='font-family:Fixedsys'>")
		'Response.Write("Uploaded File:")
		 'Gets the name of the file.
		'Response.Write("<br/>FileName: ")
		'Response.Write(mvcfile.FileName)
		FileName = mvcfile.FileName
		'Gets the size of the file.
		'Response.Write("<br/>FileSize: ")
		'Response.Write(mvcfile.FileSize)
		'Gets the temp file path. 
		'Response.Write("<br/>FilePath: ")
		'Response.Write(mvcfile.FilePath)
		'Response.Write("</div>")
		'Copys the uploaded file to a new location.    
        mvcfile.CopyTo(UploadDirectory)            
        'Moves the uploaded file to a new location.    
        mvcfile.MoveTo(UploadDirectory)   
		
		'Update the DB
		Set RS = DB.Execute("Select * from photos where PropID = " & PropID & " and image = '" & FileName & "'")
		   If RS.EOF or RS.BOF Then
   		   OrderBy = OrderBy + 1
		   SQL = "Insert INTO Photos (image, OrderBy, PropID, Show) VALUES ('" & FileName & "'," & OrderBy & ", " & PropID & ", 1)"
		   DB.Execute(SQL)
		   else
   		   DB.Execute("Update Photos Set verified  = - 1 where PropID = " & PropID & " and ID = " & RS("ID"))
		   End If
		   RS.Close
		   Set RS = Nothing
	Next
Response.Flush()	
Response.Clear
Response.Redirect("pause.asp?PropID=" & PropID & "&UID=" & UID & "&lat=" & lat & "&lng=" & lng & "&location=" & location & "&erry=Images Successfully Uploaded!")
%>
<a href="../pause.asp?PropID=<%=PropID%>&UID=<%=UID%>&lat=<%=lat%>&lng=<%=lng%>&location=<%=location%>&erry=Images Successfully Uploaded!">RETURN TO LIST OF PHOTOS</a>
<%End If%>
</div>
<!--ASP Upload End-->
</td></tr>
<tr>
  <td align="center"><a href="#" class="specialtitles" onClick="history.go(-1)"><u>CANCEL</u></a></td>
</tr>
</table>
</td></tr>
</table>
</body>
</html>

Open in new window


THANKS in advance!
0
Comment
Question by:Nico2011
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39257002
get rid of
Response.Flush()      
Response.Clear
0
 

Author Closing Comment

by:Nico2011
ID: 39258616
Thanks Padas - works great now...!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question