2014-04-20 6 views
0

내 데이터베이스의 모든 것이 실제 이미지 자체를 제외하고 채워집니다. 나는 그것을 몇 시간 동안 보았고 제출을 클릭 할 때 왜 아직도 이러한 오류가 발생하는지 파악할 수 없습니다. 나는 다른 정보를 오류를 얻고 있지만; 크기, 유형, 이름이 내 데이터베이스에 표시됩니다. 도와주세요. 여기 내 코드가있다.PHP 코드가 내 데이터베이스에서 작동하지 않습니다.

<?php 
ob_start(); 
?> 

<?php 

session_start(); 
if($_SESSION['nachos'] != "admin") 
header("Location: index.php"); 



?> 




<html xmlns="http://www.w3.org/1999/xhtml"> 


<head> 
<title>Steven Eck - Portfolio Form</title> 

<style type="text/css"> 
.auto-style1 { 
font-family: "Courier New", Courier, monospace; 
font-size: x-large; 
font-weight: bold; 
} 
.auto-style2 { 
font-family: "Courier New", Courier, monospace; 
font-weight: bold; 
font-size: medium; 
} 
.auto-style3 { 
font-family: "Courier New", Courier, monospace; 
font-size: small; 
text-decoration: blink; 
} 
</style> 

</head> 

<body style="color: #00FF00; background-color: #000000"> 
<div id="contentWrapper"> 

<div id="mainContent"> 


    <?php 
    //display form if user has not clicked submit 
    if (!('POST' == $_SERVER['REQUEST_METHOD'])) 
    { 
    ?> 
    <form enctype="multipart/form-data" action="portfolioForm.php" method="post"> 
    <fieldset> 
     <legend class="auto-style1">Project Information</legend> 
     <p><label for="txtTitle"><span class="auto-style2">Title</span>:</label> 
     <input type="text" name="txtTitle" id="txtTitle" ></p> 

     <p><span class="auto-style2"><label for="txtShortDescription">Short Description:</label></span> 
     <input type="text" name="txtShortDescription" id="txtShortDescription" ></p> 

     <p><span class="auto-style2"><label for="txtLongDescription">Long Description:</label></span> 
     <input type="text" name="txtLongDescription"id="txtLongDescription" ></p> 

     <p> 
     <input type="file" name="imgPhoto" id="imgPhoto" ></p> 

     <button type="submit">Submit</button> 

     &nbsp;<br><br><span class="auto-style3"><a href="index.php">Admin 
     Login</a></span><br class="auto-style3"><span class="auto-style3"> 
     <a href="portfolioForm.php">Portfolio Form</a></span><br class="auto-style3"> 
     <span class="auto-style3"> 
     <a href="http://www.stevesays.net/newsite.php">Main Site</a></span><br> 
     <br><br><br><br><br> 

     </fieldset> 

     </form> 

     <?php 
     } 
     //the user has submitted the form 
     else 
     { 
     echo "<form><fieldset><legend>Project Information</legend>"; 

     $dbConnection = mysqli_connect("lo***host", "we***stu_st***ck1", "r******aster", "w******u_351"); 

      if(mysqli_connect_errno()){ 
      echo '<p style="color: red;"> Failed to connect to MySql!: ' .mysqli_connect_error() . '</p>'; 
      } 
      else 
      echo 'connected'; 



     $handle = fopen($_FILES['imgPhoto']['tmpName'], "r"); 
     $image = fread($handle, filesize($_FILES['imgPhoto']['tmpName'])); 
     fclose($handle); 

     $image = mysqli_real_escape_string($dbConnection, $image); 

     mysqli_query($dbConnection, "INSERT INTO portfolio (title, shortDescription, longDescription, image, imageName, imageType, imageSize) VALUES ('$_POST[txtTitle]', '$_POST[txtShortDescription]', '$_POST[txtLongDescription]', '$image', '" . $_FILES['imgPhoto']['name']. " ', ' " . $_FILES['imgPhoto']['type']. " ', '" . $_FILES['imgPhoto']['size']. "' )"); 

     echo "<p style=\"text-align: center; font-size: 11px;\">Thanks for filling out form!</p>"; 
     echo "</fieldset></form>" ; 

     } 

     ?> 

     </div> 

이것은 내가 얻는 오류입니다. 다른 필드의 데이터는 계속 가져 오지만 이미지는 BLOB로 설정되고 절대로로드되지 않습니다.

경고 : function.fopen]) (fopen의 : 파일명은 광고에 /home/wequpstu/public_html/admin/portfolioForm.php 100

경고 빈 수 없습니다 FREAD()는 매개 변수 1 자원이 될 것으로 예상 /home/wequpstu/public_html/admin/portfolioForm.php 줄 101에 boolean이 주어진다.

경고 : fclose()는 매개 변수 1을 resource로, 부울을 /home/wequpstu/public_html/admin/portfolioForm.php에 지정한다. 온라인 102

+0

에서 비어, 그것은 같은까지 –

답변

4

오타 오류 tmpName =>tmp_name

$handle = fopen($_FILES['imgPhoto']['tmp_name'], "r"); 
    $image = fread($handle, filesize($_FILES['imgPhoto']['tmp_name'])); 
+0

정말 싫어 미안 때 밑줄. 고마워요. –

+0

@StevenEck 당신은 건강합니다. – Alex

1

오류는 매우 분명하다 : $ _FILES가 [ 'imgPhoto'] [ 'tmpName는'] 단지를 추가

$handle = fopen($_FILES['imgPhoto']['tmpName'], "r"); 
관련 문제