DZone ForumsDZone Forums  

Go Back   DZone Forums > Community > Languages & Frameworks > PHP
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
LinkBack Thread Tools Display Modes

Topic: Problem in Redirect To Another Page
Old 05-12-2008, 05:22 AM   #1 (permalink)
Member
 
Join Date: May 2008
Posts: 1
i Have created a php file uploader page and i want redirect into the another page after the file uploder function..It was working fine to me but suddently a problem came to me that header already sent...
here am attaching my sample code ..plz give me a solution to overcome tis problem asps...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<form name="form1" enctype="multipart/form-data" method="post" action="">
<table width="200" border="1" align="center" cellpadding="2" cellspacing="2" bordercolor="#0066CC">
<tr>
<td><table width="275" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="218" align="center" bgcolor="#F4F4F4"><div align="left">Attachment</div></td>
<td width="43" align="center"><input name="image" type="file" id="image"></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="Submit" value="Upload">
</td>
</tr>
<tr>
<td colspan="2" align="center" class="style1">
<?php
if($_REQUEST["Submit"] == "Upload")
{

if ($_FILES["image"]["error"] > 0)
{
echo "Return Code: " . $_FILES["image"]["error"] . "<br />";
}
else
{
if (file_exists("upload/" . $_FILES["image"]["name"]))
{
move_uploaded_file($_FILES["image"]["tmp_name"], "upload/" . $_FILES["image"]["name"]);
echo "Your File has been uploaded: " . "upload/" . $_FILES["image"]["name"];
echo $_FILES["image"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["image"]["tmp_name"], "upload/" . $_FILES["image"]["name"]);
echo "Your File has been uploaded: " . "upload/" . $_FILES["image"]["name"];
}
}

$img="upload/" . $_FILES['image']['name'];
header('location:salesenquiry.asp?a=$img');
exit;

}
?>
</td>
</tr>
<tr>
<td colspan="2" align="center">&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="center"><a href="javascript:;" class="style1" onClick="window.close();">[close window] </a></td>
</tr>
</table></td>
</tr>
</table>
</form>
</body>
</html>

plz give the answer asps.

the error msg to tis code is,,

Your file has been uploaded: API-CLEANING VALIDATION.pdf
Warning: Cannot modify header information - headers already sent by (output started at c:\Inetpub\vhosts\appleintlgroup.com\httpdocs\news upload.php:10) in c:\Inetpub\vhosts\appleintlgroup.com\httpdocs\news upload.php on line 49
jithu_php is offline   Reply /w Quote -


Old 05-19-2008, 11:16 AM   #2 (permalink)
Member
 
Join Date: May 2008
Posts: 1
If everything was working fine and suddenly you had this problem - like you say, and if the file was recently edited maybe a unwanted character is at the start of the php file?

Try this.

Open your page in 'edit' the old dos editor or something similar check if a nonprintable character is displayed - remove that hopefully it will work.
nidash is offline   Reply /w Quote -


Thread Tools
Display Modes



All times are GMT -5. The time now is 02:52 AM.