Jump to content

download code


jalaladdin

Recommended Posts

That's like saying "when I feel sick, I take these GREEN PILLS, and I feel better. I don't know how they work, but they do. Every time!" :)More, perhaps, like surrounding your entire code in a try...catch block.The warning occurs because you are trying to send a header after the headers have already been sent. This is commonly caused by starting the transmission of the response body, as all headers need to be sent by that point. Output buffering delays the sending of the response body, and thus the error disappears. However, the issue is usually symptomatic and just making the error message go away, like you are doing, is unlikely to fix the underlying flaws in the code.

Link to comment
Share on other sites

Hi!Now Ur Path Is Fine...Ok Use These Code For This Error...
<?php ob_start(); // AT TOP OF YOUR PAGE ?><?php// USE ALL YOUR PAGE CODE?><?php ob_flush(); // AT BOTTOM OF YOUR PAGE ?>

i use this code IE show me after topic error message but i can resolve this error mesage
Link to comment
Share on other sites

this code is working now but when i download file .i open file ,file show me error messageadobe reader could not open'php.pdf'because it is either not a supported filetype or because the file has been damaged(for example ,it was sent as an email attacjhment and wasn't correctly decoded

<?phpob_start();?> <?phpsession_start();if($_SESSION['username']){ $link=mysql_pconnect("localhost","root","");  mysql_select_db("tree",$link);$result=mysql_query("select `file_name` from `pdf` where `file_id`='".intval($_GET['id'])."'")or die(mysql_error());   if(mysql_num_rows($result)>0 ){	   $row=mysql_fetch_assoc($result);	   $file=$row['file_name'];	   $type="application/pdf";	   $data=file_get_contents("pdf/".$file);	   $size=strlen($data);	   header("content-disposition:attachment; filename=$file");	   header("content-type:$type");	   header("content-length:$size");	   echo $data;	   	      }else   echo "File id not found";   	    }else   echo('		<br/>		<div align="center" class=" bg-text1" > please login  </div>		<br/>		<a href="register.html" ><div align="center" class="">register </a></div>		');   ?> <?phpob_end_flush();?>

Link to comment
Share on other sites

i am Trying to open the file in Notepad.notepad show me this error meesage <br /><b>Fatal error</b>: Allowed memory size of 8388608 bytes exhausted (tried to allocate 7188481 bytes) in <b>C:\wamp\www\4\download.php</b> on line <b>22</b><br />

Link to comment
Share on other sites

First, remove the output buffering code. There's a newline near the top of the file that gets sent as output that is almost definitely going to corrupt any file.Second, your memory limit is set too low, to only 8MB. You should raise that to 128MB. You can use ini_set at runtime to set the memory_limit option, but you can't set it to a higher value than what's in php.ini. Ask your host to increase the memory limit to 128MB in php.ini.http://www.php.net/manual/en/ini.core.php#ini.memory-limit

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...