jasonhardwick Posted May 6, 2008 Share Posted May 6, 2008 Hi all... Ok i'm building a forum with images and here is my code PHP Code: <? include "config.php"; $tbl_name="forum_question"; $topic=$_POST['topic']; $detail=$_POST['detail']; $name=$_POST['name']; $email=$_POST['email']; $username=$_POST['username']; $datetime=date("d/m/y h:i:s"); //create date time $hndl=fopen($_REQUEST["imgfile"],"r"); $isize=sizeof($_REQUEST["imgfile"]); $imgdata=""; while(!feof($hndl)){ $imgdata.=fread($hndl,$isize); }; $imgdata=addslashes($imgdata); $sql="INSERT INTO $tbl_name(username, topic, detail, name, email, datetime)VALUES('$username', '$topic', '$detail', '$name', '$email', '$datetime')"; $sql = "INSERT INTO $tbl_name VALUES(NULL,'". $_REQUEST["imgtype"] ."','". $imgdata ."')"; $result=mysql_query($sql); fclose($hndl); echo "<a href=\"test_imagedb_view.php\">view image</a>"; if($result){ echo "Sucess!!<BR>"; echo "<a href=main_forum.php>View your topic</a>"; echo "<br />"; echo "<a href=main_forum.php>Return to Post Home</a>"; } else { echo "ERROR"; } mysql_close(); ?> but it keeps returning this error any ideas why? Warning: feof(): supplied argument is not a valid stream resource in /home/content/j/a/s/jasonhardwick/html/add_topic.php on line 101 Warning: fread(): supplied argument is not a valid stream resource in /home/content/j/a/s/jasonhardwick/html/add_topic.php on line 102 Link to comment https://forums.phpfreaks.com/topic/104313-error/ Share on other sites More sharing options...
Fadion Posted May 6, 2008 Share Posted May 6, 2008 What is $_REQUEST["imgfile"]? Post, get, session or what? Link to comment https://forums.phpfreaks.com/topic/104313-error/#findComment-534116 Share on other sites More sharing options...
jasonhardwick Posted May 6, 2008 Author Share Posted May 6, 2008 POST here is the code <? session_start(); if (empty($_SESSION['username'])){ header("location:index1.php"); exit; } ?> <!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" /> <meta name="author" content="realitysoftware.ca" /> <title>My Creative Process Links - Post New Creative</title> <link rel="stylesheet" type="text/css" href="css/style.css" /> <style type="text/css"> <!-- .style1 { color: #f73602; font-weight: bold; } --> </style> </head> <body> <div id="main"> <div id="navbar"></div> <div id="header"> <div id="left_bar_header"><span class="title_dark">MY CREATIVE </span> <span class="title"> PROCESS </span> <p>This site was developed as a link for the creative community. It is an area where we can come to get feed back on our ideas and designs. A great designer never forgets that everyone needs a second opinion sometimes.</p> </div> <div id="right_bar_header"><img src="images/head_bckg_right.jpg" alt="" /></div> </div> <div id="content"> <table width="95%" border="0" align="center" cellpadding="5"> <tr> <td><a href="/index.php">home</a> | <a href="/main_forum.php">review</a> | <a href="/create_topic.php">post</a> | <a href="/mindgames.php">mindgames</a> | <a href="/archive.php">archive</a> | <a href="/brainstorm.php">brainstorm</a> | <a href="/my_account.php">my account</a> | <a href="/suggestion_box.php">suggestion box</a></td> <td><div align="right"><a href="/login.php">login</a></div></td> </tr> </table> <table width="95%" border="0" align="center"> <tr> <td height="0" valign="top"><h1><span class="red">Post </span> Creative</h1></td> <td valign="top"> </td> <td valign="top"> </td> <td width="180" rowspan="4" valign="top"><div align="right"> <p class="style1">Sponsored Links</p> <p><a href="/links/schools.php" target="_blank">Creative Schools</a></p> <p><a href="/links/careers.php" target="_blank">Creative Careers</a></p> <p><a href="/links/publications.php" target="_blank">Creative Publications</a></p> <p><a href="/links/professionals.php" target="_blank">Creative Professionals</a></p> <p><a href="/links/creative.php" target="_blank">General Creative Links</a></p> <p><a href="/links/photography.php" target="_blank">Photography Links</a></p> <p><a href="/links/art.php" target="_blank">Art Links</a></p> <p><a href="/links/design.php" target="_blank">Design links</a></p> <p><a href="/links/illustration.php" target="_blank">Illustration Links</a></p> <p><a href="/links/web.php" target="_blank">Web Links</a></p> <p><a href="/links/3d.php" target="_blank">3D Design Links</a></p> <p><a href="/links/id.php" target="_blank">Interior Design Links</a></p> </div></td> </tr> <tr> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"> </td> </tr> <tr> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"> </td> </tr> <tr> <td valign="top"><p> </p> <table width="400" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form id="form1" name="form1" method="post" action="add_topic.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3" bgcolor="#E6E6E6"><strong>Create New Topic</strong> </td> </tr> <tr> <td width="14%"><strong>Topic</strong></td> <td width="2%">:</td> <td width="84%"><input name="topic" type="text" id="topic" size="50" /></td> </tr> <tr> <td valign="top"><strong>Detail</strong></td> <td valign="top">:</td> <td><textarea name="detail" cols="50" rows="3" id="detail"></textarea></td> </tr> <tr> <td><strong>Type</strong></td> <td>:</td> <td> <select name="imgtype"><option value="image/gif">GIF</option><option value="image/jpeg">JPEG</option></select></td> </tr> <tr> <td>Image</td> <td>:</td> <td><input type="file" name="imgfile"></td> </tr> <tr> <td><strong>Email</strong></td> <td>:</td> <td><input name="email" type="text" id="email" size="50" /></td> </tr> <tr> <td> </td> <td> </td> <td><input name="username" type="hidden" id="username" value = "<?php echo $username ?>"/><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td> </tr> </table> </td> </form> </tr> </table></td> <td valign="top"></td> <td valign="top"></td> </tr> </table> <p></p> <p> </p> <div id="content"> <div class="secondary_page_first_column" id="secondary_page_first_column"></div> </div> </div></div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/104313-error/#findComment-534137 Share on other sites More sharing options...
jasonhardwick Posted May 6, 2008 Author Share Posted May 6, 2008 can anyone help? Link to comment https://forums.phpfreaks.com/topic/104313-error/#findComment-534287 Share on other sites More sharing options...
Fadion Posted May 6, 2008 Share Posted May 6, 2008 Its not post, it is file!! Surely it is submitted by a post method, but it is access via $_FILES. The best way to fopen it is by saving it first, but u can still access the temporary file with $_FILES['imgfile']['tmp_name']. Take a look at $_FILES to get the idea. Link to comment https://forums.phpfreaks.com/topic/104313-error/#findComment-534333 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.