inspire Posted October 5, 2007 Share Posted October 5, 2007 i am using php 4.05 in windows . my problem is i cannot upload image inside the database. anyone can help me solve the problem. ??? <?php mysql_connect("localhost", "root", "") or die("no connection"); mysql_select_db("lab") or die("no database"); if(isset($_POST['upload']) && $HTTP_POST_FILES['userfile']['size'] > 0) { $fileName = $HTTP_POST_FILES['userfile']['name']; $tmpName = $HTTP_POST_FILES['userfile']['tmp_name']; $fileSize = $HTTP_POST_FILES['userfile']['size']; $fileType = $HTTP_POST_FILES['userfile']['type']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $query = "INSERT INTO upload (name, size, type, content ) ". "VALUES ('$fileName', '$fileSize', '$fileType', '$content')"; mysql_query($query) or die('Error, query failed'); echo "<script languange = 'Javascript'> alert('File $fileName uploaded'); location.href = 'LMS-upload1.php'; </SCRIPT>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/71935-upload-not-work/ Share on other sites More sharing options...
suma237 Posted October 5, 2007 Share Posted October 5, 2007 check this site http://www.tizag.com/phpT/fileupload.php Quote Link to comment https://forums.phpfreaks.com/topic/71935-upload-not-work/#findComment-362310 Share on other sites More sharing options...
DanDaBeginner Posted October 5, 2007 Share Posted October 5, 2007 what is the datatype of your field for uploaded file?? Quote Link to comment https://forums.phpfreaks.com/topic/71935-upload-not-work/#findComment-362358 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.