zhq Posted December 12, 2006 Share Posted December 12, 2006 Hi,I got the following error message. I don't know what cause this problem. Please help. Thanks a lot in advance.zhq***Warning: file_get_contents(http://localhost/uploadfiles/Process.pdf) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in c:\inetpub\wwwroot\vlsi\forward.php on line 18Warning: fopen(http://zhenghq/uploadfiles/Process.pdf) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in c:\inetpub\wwwroot\forward.php on line 66Warning: fread(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\forward.php on line 26Warning: fclose(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\forward.php on line 68***the code is here:***<?phpinclude("download_header.php");header("Cache-control: no-cache");$filedir = "http://" . $HTTP_SERVER_VARS['HTTP_HOST'] . "/"; $tempdir = $filedir . "temp/"; $filedir = $filedir . "uploadfiles/"; $redirect = "http://" . $HTTP_SERVER_VARS['HTTP_HOST'] . "/";$redirect = $redirect . "download_main.php";function RemoteFileSize($remote_file){echo "<pre>"; var_dump($remote_file); $file = file_get_contents($remote_file); return strlen($file);} function Longfread($handle, $size){ $contents = ""; do { $data = fread($handle, $size); if (strlen($data) == 0) { break; } $contents .= $data; } while(true); return $contents;}if (isset($_GET['page'])){ $page=$_GET['page']; mysql_connect("localhost","root","") or die ("Unable to connect to MySQL server."); $db = mysql_select_db("nus") or die ("Unable to select requested database."); $sql = "SELECT f_name from file WHERE f_ID=\"$page\""; $result = mysql_query($sql); if($result){ if (mysql_num_rows($result) == 0){ echo "This file may not exist in database. Please enter your administrator name correctly. <a href=$redirect>BACK</a>.<br>"; exit(); } else{ $row_array = mysql_fetch_row($result); $filename = $row_array[0]; //$filename ="logout.pdf"; //$tempdir=$tempdir.$filename; echo"<pre>"; var_dump($filename); $filedir=$filedir.$filename; echo"<pre>"; var_dump($filedir); $filesize=RemoteFileSize($filedir); //header("Content-Type: application/pdf"); //header("Content-Length: ".$filesize); //header("Content-Disposition: inline; filename=$filename"); $fp = fopen($filedir, 'rb'); $pdf_buffer = Longfread($fp, 8192); fclose ($fp); print $pdf_buffer; exit(); //header("Location: $filedir"); //exit(); } }}else{ header("Location: $redirect");} Link to comment https://forums.phpfreaks.com/topic/30327-failed-to-open-stream/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.